This proposal was discussed at this pull request and amended by this one.
Export ~ from Data.Type.Equality¶
Motivation¶
The ~ type operator is magical, in that it’s always in scope and does not require TypeOperators to use.
But ~~, :~:, and :~~: are not magical in the same way, they are
exported from Data.Type.Equality and require TypeOperators.
This is a historical accident which we propose to correct.
Proposed Change Specification¶
Do not bring
~into scope magically, export it fromData.Type.Equality.Re-export
~fromPrelude.Drop the requieremnt to enable
TypeFamiliesorGADTsto use the~type operator.Require
TypeOperatorsto use the~type operator.
Migration story¶
Let n be the GHC version that implements this proposal.
Starting with GHC n, include a compatibility fallback:
When the lookup for
~fails because it is not in scope, assume it refers toData.Type.Equality.~. When this happens and-Wtype-equality-out-of-scope(included in-Wcompat) is in effect, emit a warning.When the use of
~would have been rejected becauseTypeOperatorsare not enabled, accept the program regardless. When this happens and-Wtype-equality-requires-operators(enabled by default) is in effect, emit a warning.
Starting with GHC n+2, enable both warnings by default.
Either starting with GHC n+8 or with the next major compiler version bump (GHC
10), whichever comes first, remove the compatibility fallback.
Effect and Interactions¶
One less quirk.
The users are allowed to define their own
~.The compiler internals are simplified, in particular things described in
Note [eqTyCon (~) is built-in syntax].Haddock documentation for
~will get fixed (it is currently missing in the generated HTML).
Costs and Drawbacks¶
This is a breaking change:
Users will need to enable
TypeOperatorsAuthors of custom preludes will likely want to re-export
(~)
Alternatives¶
Keep
~special for historical reasons to avoid a breaking change.A different migration schedule (e.g. include the warning in
-Wallfirst).
Unresolved Questions¶
None.
Implementation Plan¶
There’s a prototype implementation in MR 4313.