I feel like I don't have a lot of examples of languages where a wrapper on an entity is routinely passed around as a proxy for the entity itself except for the ones in the same "we decided to make a mass-market version of OCaml around 2015" cohort as Rust.
Conversation
I see. In OOP you'd see at most a case of Vec<T> vs T, while in languages with enums the Container<T> vs T problem crops up more often. That's fair.
1
Yeah. And like in C++ we have things like smart pointers/unique_ptr, but C++ doesn't work.
1
1
(...Similarly the more conventional ML have the Tag(entity) vs entity problem, but those languages seem to really dislike subtyping (ie concepts such as traits) so they can't get into this particular hole so easily.)
1
1
Actually, I wonder if Haskell has variants of this problem (because typeclasses are not completely dissimilar from traits), and what their current error message is.
1
2
Elm?
1
Elm doesn't have ad-hoc polymorphism, except for hard-wired `comparable` and `number` type parameters, so it probably won't be super helpful. Haskell does have a nice way of providing domain-specific error messages for type classes though. Not sure if it would help here though.
2
For more info on this you can see this blog post: kodimensional.dev/type-errors - it's a super useful feature, but sadly not used all that much in the Haskell ecosystem.



