Display struct definition

Is there an easy way to display a struct definition?
I often find myself wanting to see the fieldnames for a type, for which I can call fieldnames(mytype). This doesn’t give me the corresponding types as well. Is there an easy way to say, call @printstruct(typeof(mytype)) and get:

struct MyType
    var1::Int
    var2::Vector{String}
end

or similar?

julia> using HTTP

julia> HTTP.Response
HTTP.Response

julia> dump(HTTP.Response)
HTTP.Response <: Any
  status::Int32
  major::Int16
  minor::Int16
  cookies::Array{HTTP.Cookies.Cookie,1}
  headers::Dict{String,String}
  body::HTTP.FIFOBuffers.FIFOBuffer
  request::Nullable{HTTP.Request}
  history::Array{HTTP.Response,1}

8 Likes