# Customizing console display of the information within an abstract type instance

**URL:** https://discourse.julialang.org/t/customizing-console-display-of-the-information-within-an-abstract-type-instance/9391
**Category:** General Usage
**Tags:** question, type
**Created:** [February 28, 2018, 3:32pm UTC](https://discourse.julialang.org/t/customizing-console-display-of-the-information-within-an-abstract-type-instance/9391 "2018-02-28T15:32:58Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![hockey-model-julia](https://avatars.discourse-cdn.com/v4/letter/h/a88e57/32.png) [@hockey-model-julia](https://discourse.julialang.org/u/hockey-model-julia)
#### Post date: [February 28, 2018, 3:32pm UTC](https://discourse.julialang.org/t/customizing-console-display-of-the-information-within-an-abstract-type-instance/9391/1 "2018-02-28T15:32:58Z")

</div>

This question is probably applicable to multiple packages, but the example I am familiar with and want to somewhat replicate is from the `HypothosisTests` package.

When an instance of a `HypothesisTests.OneSampleTTest` is put into the console it displays the name of the test, population details, test summary, and details. The fields are also accessible but are not exactly the same as that list. How does the design of the `HypothesisTests` abstract type display that information and contain different information?

---

<div class="post-metadata">

### Author: ![andreasnoack](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/andreasnoack/32/27_2.png) [@andreasnoack](https://discourse.julialang.org/u/andreasnoack)
#### Post date: [February 28, 2018, 4:14pm UTC](https://discourse.julialang.org/t/customizing-console-display-of-the-information-within-an-abstract-type-instance/9391/2 "2018-02-28T16:14:39Z")

</div>

The custom printing of types is documented [here](https://docs.julialang.org/en/stable/manual/types/#Custom-pretty-printing-1). The key is to overload `Base.show(::IO, ::YourType)`. In the `OneSampleTTest` case the relevant definition is

[https://github.com/JuliaStats/HypothesisTests.jl/blob/b28a4587fe441d1da0479c0791e5f9fd2120cb6b/src/HypothesisTests.jl#L102-L138](https://github.com/JuliaStats/HypothesisTests.jl/blob/b28a4587fe441d1da0479c0791e5f9fd2120cb6b/src/HypothesisTests.jl#L102-L138)

An easy way to find the definition is often to call

```julia
julia> t = OneSampleTTest(randn(100), 0.1);

julia> @which show(STDOUT, t)
show(io::IO, test::T) where T<:HypothesisTests.HypothesisTest in HypothesisTests at /Users/andreasnoack/.julia/v0.6/HypothesisTests/src/HypothesisTests.jl:103

```
