# Structural subtyping

**URL:** <https://discourse.julialang.org/t/structural-subtyping/64354>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 9, 2021, 1:53pm UTC](https://discourse.julialang.org/t/structural-subtyping/64354 "2021-07-09T13:53:37Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [July 10, 2021, 9:52pm UTC](https://discourse.julialang.org/t/structural-subtyping/64354/9 "2021-07-10T21:52:45Z")

</div>

Afaik the reason you can do

```julia
julia> struct Foo end

julia> enumerate(Foo())
enumerate(Foo())

```

isn’t based on principle since it doesn’t have much (any?) benefit. It’s more just due to the technical reason that Julia hasn’t figured out its trait system yet.

I think Julia’s sparse use of type signatures is a significant problem for correctness, composability, and documentation.

I don’t agree with using

> [@tisztamo](#):
>
> function signatures _only for dispatch_ , and not for safety or other motivations of restricting.

IMO, the solution is likely to be a trait system (like [WhereTraits.jl](https://github.com/schlichtanders/WhereTraits.jl)), but there are some [significant issues](https://discourse.julialang.org/t/announcing-traits-jl-a-revival-of-julia-traits/35683/13) that need to be worked out before such a system can be widely deployed.

A related issue that Julia has is that it can’t currently represent higher order functions in the type system. For example, it’s not currently possible to write a signature for `map`. This makes it hard to write more sophisticated functional structures because there’s no help from the compiler and no signatures to guide the author.

---

_[View the full topic](https://discourse.julialang.org/t/structural-subtyping/64354)._
