Display Julia types in a more human-friendly way.
Author MrVPlusOne
4 Stars
Updated Last
1 Year Ago
Started In
November 2020


Build Status Coverage

Display Julia types in a more human-friendly way.


This package provides alternative type printing functions to make it easier to read Julia types. So instead of having to read messy outputs like this: Before.png

Using this package, we can overwrite, ::Type) to achieve a much cleaner result: After.png


First, install the package with

Using Pkg; Pkg.add("SimpleTypePrint")

You can then override the default type printing behavior by calling

config_type_display(max_depth=3, short_type_name=true)

If you prefer not to override the Julia default, you can instead use the provided show_type(io, type; kwargs...) and repr_type(type; kwargs...) function to manually print selected types.

Changes compared to

Merging nested where clauses

By default, Julia display multiple where clauses separately, whereas in SimpleTypePrint, where clauses are correctly merged, just like how you would write them.

Input Tuple{A,B,C} where {A, B, C} Tuple{A,B,C} where C where B where A
SimpleTypePrint Tuple{A,B,C} where {A,B,C}

Displaying deeply nested parts as ellipsis

The default max display depth is 3, but you can change this value using the max_depth keyword argument.

Input Tuple{Tuple{Tuple{A,B},C},D} where {A,B,C,D} Tuple{Tuple{Tuple{A,B},C},D} where D where C where B where A
SimpleTypePrint(max_depth=3) Tuple{Tuple{Tuple{...},C},D} where {A,B,C,D}

Displaying type names without module prefixes

By default, Julia displays module prefixes unless the type is directly visible from the current scope. SimpleTypePrint allows you to opt-out from this behavior.

julia> module A
           module B
               struct Foo{A} end
       end  # Foo is nested inside A and B.
Input A.B.Foo Main.A.B.Foo
SimpleTypePrint(short_type_name=true) Foo{A} where A

Renaming type variables with conflicting names

Input Tuple{(Tuple{A} where A), A} where A Tuple{Tuple{A} where A,A} where A
SimpleTypePrint Tuple{Tuple{A1} where A1,A} where A