[Haskell-cafe] working my way through Data.Type.Equality...my head hurts...

oleg at okmij.org oleg at okmij.org
Wed Jan 14 08:47:52 UTC 2015

Richard Eisenberg wrote:
> `~` is simply equality on types. The constraint `a ~ b` means that `a`
> is the same type as `b`. We could have spelled it `=` if that weren't
> used elsewhere. Before `~` was added to GHC, it might have been
> implemented like this:

> class Equals a b | a -> b, b -> a
> instance Equals x x
> -- no other instances!

Actually, `~' has been implemented, back in 2004, and the
implementation quite a bit more involved than the above (although
still taking a couple of lines). The `~' constrain was called TypeCast
back then, and there is a page about it explaining the benefits and
peculiarities of the implementation.


Perhaps the many examples of TypeCast make it less mysterious.

More information about the Haskell-Cafe mailing list