diff options
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/9.4.1-notes.rst | 21 | ||||
-rw-r--r-- | docs/users_guide/using-warnings.rst | 44 |
2 files changed, 62 insertions, 3 deletions
diff --git a/docs/users_guide/9.4.1-notes.rst b/docs/users_guide/9.4.1-notes.rst index a2cced7294..caac4e9362 100644 --- a/docs/users_guide/9.4.1-notes.rst +++ b/docs/users_guide/9.4.1-notes.rst @@ -22,9 +22,24 @@ Language If you want to retain the old behavior, add a (backward-compatible) type signature, explicitly requesting this unusual quantification. -- GHC no longer checks for ``-XGADTs`` or ``-XTypeFamilies`` in order to use - an equality constraint in a type. This is part of accepted proposal - `#371 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0371-non-magical-eq.md>`_. +- GHC Proposal `#371 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0371-non-magical-eq.md>`_ has been implemented. This means: + + * The use of equality constraints no longer requires ``-XGADTs`` or ``-XTypeFamilies``. + + * The use of equality constraint syntax ``a ~ b`` requires ``-XTypeOperators``, + otherwise results in a warning (:ghc-flag:`-Wtype-equality-requires-operators`). + + * ``(~)`` is now a legal name for a user-defined type operator: + :: + + class a ~ b where + ... + + This used to be rejected with "Illegal binding of built-in syntax". + + * The built-in type equality is now exported from ``Data.Type.Equality`` and + re-exported from ``Prelude``. When ``(~)`` is not in scope, its use results + in a warning (:ghc-flag:`-Wtype-equality-out-of-scope`). - There were previously cases around functional dependencies and injective type families where the result of type inference would depend on the order diff --git a/docs/users_guide/using-warnings.rst b/docs/users_guide/using-warnings.rst index 5b0093b650..5b2c85099b 100644 --- a/docs/users_guide/using-warnings.rst +++ b/docs/users_guide/using-warnings.rst @@ -65,6 +65,7 @@ To reverse ``-Werror``, which makes all warnings into errors, use ``-Wwarn``. * :ghc-flag:`-Wunicode-bidirectional-format-characters` * :ghc-flag:`-Wforall-identifier` * :ghc-flag:`-Wgadt-mono-local-binds` + * :ghc-flag:`-Wtype-equality-requires-operators` The following flags are simple ways to select standard "packages" of warnings: @@ -161,6 +162,7 @@ The following flags are simple ways to select standard "packages" of warnings: * :ghc-flag:`-Wnoncanonical-monoid-instances` * :ghc-flag:`-Wstar-is-type` * :ghc-flag:`-Wcompat-unqualified-imports` + * :ghc-flag:`-Wtype-equality-out-of-scope` .. ghc-flag:: -Wno-compat :shortdesc: Disables all warnings enabled by :ghc-flag:`-Wcompat`. @@ -2286,6 +2288,48 @@ of ``-W(no-)*``. to pattern match on a GADT if neither :extension:`GADTs` nor :extension:`TypeFamilies` were enabled. +.. ghc-flag:: -Wtype-equality-out-of-scope + :shortdesc: warn when type equality ``a ~ b`` is used despite being out of scope + :type: dynamic + :reverse: -Wno-type-equality-out-of-scope + + :since: 9.4.1 + + In accordance with `GHC Proposal #371 + <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0371-non-magical-eq.md>`__, + the type equality syntax ``a ~ b`` is no longer built-in. Instead, ``~`` is + a regular type operator that can be imported from ``Data.Type.Equality`` or + ``Prelude``. + + To minimize breakage, a compatibility fallback is provided: whenever ``~`` + is used but is not in scope, the compiler assumes that it stands for a type + equality constraint. The warning is triggered by any code that relies on + this fallback. It can be addressed by bringing ``~`` into scope explicitly. + + The likely culprit is that you use :extension:`NoImplicitPrelude` and a + custom Prelude. In this case, consider updating your custom Prelude to + re-export ``~`` from ``Data.Type.Equality``. + + Being part of the :ghc-flag:`-Wcompat` option group, this warning is off by + default, but will be switched on in a future GHC release. + +.. ghc-flag:: -Wtype-equality-requires-operators + :shortdesc: warn when type equality ``a ~ b`` is used despite being out of scope + :type: dynamic + :reverse: -Wno-type-equality-requires-operators + + :since: 9.4.1 + + In accordance with `GHC Proposal #371 + <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0371-non-magical-eq.md>`__, + the type equality syntax ``a ~ b`` is no longer built-in. Instead, ``~`` is + a regular type operator that requires the :extension:`TypeOperators` extension. + + To minimize breakage, ``~`` specifically (unlike other type operators) can + be used even when :extension:`TypeOperators` is disabled. The warning is + triggered whenever this happens, and can be addressed by enabling the + extension. + If you're feeling really paranoid, the :ghc-flag:`-dcore-lint` option is a good choice. It turns on heavyweight intra-pass sanity-checking within GHC. (It checks GHC's sanity, not yours.) |