# How to make own type explanation in Workspace?

**URL:** <https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191>\
**Category:** New to Julia\
**Created:** [July 9, 2019, 4:16pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191 "2019-07-09T16:16:37Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PharmCat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pharmcat/32/6953_2.png) [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Post date:** [July 9, 2019, 4:16pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/1 "2019-07-09T16:16:37Z")

</div>

How to make own type explanation in Workspace for my type like HypothsisTest or GLM.

I see only type name and variable names, but for other types like GLM there are prety text output.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [July 9, 2019, 4:27pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/2 "2019-07-09T16:27:21Z")

</div>

I assume you are talking about docstrings? If so, check out [Documentation · The Julia Language](https://docs.julialang.org/en/v1/manual/documentation/)

---

<div class="post-metadata">

**Author:** ![jonathanBieler](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jonathanBieler](https://discourse.julialang.org/u/jonathanBieler)\
**Post date:** [July 9, 2019, 4:37pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/3 "2019-07-09T16:37:09Z")

</div>

I think it’s rather pretty printing:

[https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing-1](https://docs.julialang.org/en/v1/manual/types/#man-custom-pretty-printing-1)

---

<div class="post-metadata">

**Author:** ![PharmCat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pharmcat/32/6953_2.png) [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Post date:** [July 9, 2019, 8:04pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/4 "2019-07-09T20:04:38Z")

</div>

Hi, I am using this feature, but it leads only for changing in console output.

I try code:

```julia
struct ConfidenceInterval
    lower::Real
    upper::Real
    estimate::Real
end

function Base.show(io::IO, ::MIME"text/plain", obj::ConfidenceInterval)
    compact = get(io, :compact, false)
    println(io, "Confidence interval:")
    if compact
       print(io, "Upper: $(obj.upper) , Lower: $(obj.lower)")
    else
       println(io, "Upper: ", obj.upper)
       println(io, "Lower: ", obj.lower)
   end
end

Docs.getdoc(obj::ConfidenceInterval) = "ConfidenceInterval $(obj.estimate)"

ci = ConfidenceInterval(2,1,3)

```

And this not help to get result like in green rectangle… only boring red…

 ![workspace](https://global.discourse-cdn.com/julialang/original/3X/3/9/3905b2e40fe6e8278d3dad7fd8ad879d5318abca.png)

---

<div class="post-metadata">

**Author:** ![asinghvi17](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/asinghvi17/32/8272_2.png) [@asinghvi17](https://discourse.julialang.org/u/asinghvi17)\
**Post date:** [July 11, 2019, 6:32am UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/5 "2019-07-11T06:32:29Z")

</div>

You may find this code to be of interest:

> <https://github.com/JuliaDynamics/DynamicalSystemsBase.jl/blob/0da9f4114e71b9468327f971cefdfa53b4f1e210/src/discrete.jl#L272-L318>

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [July 11, 2019, 6:42am UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/6 "2019-07-11T06:42:52Z")

</div>

I don’t know what io context the juno variable browser uses (maybe @pfitzseb can help), but the show function you defined should work if you do `print(ci)` and look at the repl output

---

<div class="post-metadata">

**Author:** ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)\
**Post date:** [July 11, 2019, 7:46am UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/7 "2019-07-11T07:46:44Z")

</div>

Right now you need to overload `Base.show(io::IO, obj::ConfidenceInterval)`, and not the three argument form. This is consistent with what the help for `show` says:

> The default MIME type is `MIME"text/plain"`. There is a fallback definition for `text/plain` output that calls `show` with 2 arguments. Therefore, this case should be handled by defining a 2-argument `show(io::IO, x::MyType)` method.

I think we [can safely check for both forms though](https://github.com/JunoLab/Atom.jl/pull/143).

---

<div class="post-metadata">

**Author:** ![PharmCat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pharmcat/32/6953_2.png) [@PharmCat](https://discourse.julialang.org/u/PharmCat)\
**Post date:** [July 11, 2019, 1:47pm UTC](https://discourse.julialang.org/t/how-to-make-own-type-explanation-in-workspace/26191/8 "2019-07-11T13:47:58Z")

</div>

Thx! Its my fault:

`Base.show(io::IO, obj::ConfidenceInterval)` instead of `Base.show(io::IO, ::MIME"text/plain", obj::ConfidenceInterval)` works perfectly!
