Skip to content

Export (~) from Data.Type.Equality

The (~) type operator is currently considered built-in syntax, with the following consequences:

  1. The user is not allowed to define their own type constructors with this name:

    ghci> class a ~ b
    <interactive>:1:1: error: Illegal binding of built-in syntax: ~
  2. Writing a ~ b does not require enabling -XTypeOperators.

  3. The ~ type operator is always in scope.

I created GHC Proposal #371 to discuss making it an entirely ordinary type operator. However, that would be a breaking change.

This ticket is to discuss a less intrusive change: export the (~) from Data.Type.Equality, but also let the user define their own. In the implementation, this just means that if we failed to look up ~, default to Data.Type.Equality.~.

This ticket is to track the implementation of that (now accepted) proposal.

As the result:

  • Users can define their own, entirely ordinary ~~~, while the built-in ~ remains magical.~~
  • Haddock can display the documentation for the built-in ~ (currently it is unable to do so).
Edited by Vladislav Zavialov
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information