# Print name of type w/o parameters, Julia 1.0-master

**URL:** <https://discourse.julialang.org/t/print-name-of-type-w-o-parameters-julia-1-0-master/45447>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 24, 2020, 10:43am UTC](https://discourse.julialang.org/t/print-name-of-type-w-o-parameters-julia-1-0-master/45447 "2020-08-24T10:43:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 24, 2020, 10:43am UTC](https://discourse.julialang.org/t/print-name-of-type-w-o-parameters-julia-1-0-master/45447/1 "2020-08-24T10:43:19Z")

</div>

Given a parametric type `T` I would like to print (or, equivalently, obtain as a `String`) the name of this type without parameters. The purpose is pretty-printing a complicated type.

I need a generic solution, not one that depend on defining methods for particular types. `Base.typename` used to work for this, but recent changes on `master` broke this.

MWE of how I did it previously:

```julia
struct Foo{N} end

struct Bar{T}
    x::T
end

Base.show(io::IO, b::Bar) = print(io, "Bar with $(Base.typename(typeof(b.x)))")

julia> Bar(Foo{Int}())
Bar with Foo

```

but note

```julia
julia> VERSION
v"1.6.0-DEV.707"

julia> Bar(Foo{Int}())
Bar with typename(Foo)

```

Ideally a solution would work for all versions, but I can also condition this code or use `Compat`.

---

<div class="post-metadata">

**Author:** ![tamasgal](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamasgal/32/27946_2.png) [@tamasgal](https://discourse.julialang.org/u/tamasgal)\
**Post date:** [August 24, 2020, 11:18am UTC](https://discourse.julialang.org/t/print-name-of-type-w-o-parameters-julia-1-0-master/45447/2 "2020-08-24T11:18:30Z")

</div>

I am wondering if the recent changes in master are maybe unintentional. Given that it seems to be the only reason to change your code, reverting that might be the better solution?

I am asking mostly since it looks weird to me that `typename()` outputs “typename”. That looks redundant…

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [August 24, 2020, 11:19am UTC](https://discourse.julialang.org/t/print-name-of-type-w-o-parameters-julia-1-0-master/45447/3 "2020-08-24T11:19:46Z")

</div>

Well, since it is not exported, I can’t complain.

In the meantime, I realized that I can just use `nameof` and it does what I want.
