diff --git a/docs/users_guide/8.0.1-notes.rst b/docs/users_guide/8.0.1-notes.rst --- a/docs/users_guide/8.0.1-notes.rst +++ b/docs/users_guide/8.0.1-notes.rst @@ -304,6 +304,10 @@ :ghc-flag:`-this-unit-id` or, if you need compatibility over multiple versions of GHC, :ghc-flag:`-package-name`. +- When :ghc-flag:`-fdefer-type-errors` is enabled and an expression fails to + typecheck, ``Control.Exception.TypeError`` will now be thrown instead of + ``Control.Exception.ErrorCall``. + GHCi ~~~~ @@ -527,6 +531,10 @@ - Enable ``PolyKinds`` in the ``Data.Functor.Const`` module to give ``Const`` the kind ``* -> k -> *`` (see :ghc-ticket:`10039`). +- Add the ``TypeError`` datatype to ``Control.Exception``, which represents the + error that is thrown when an expression fails to typecheck when run using + :ghc-flag:`-fdefer-type-errors`. (see :ghc-ticket:`10284`) + binary ~~~~~~ diff --git a/libraries/base/Control/Exception/Base.hs b/libraries/base/Control/Exception/Base.hs --- a/libraries/base/Control/Exception/Base.hs +++ b/libraries/base/Control/Exception/Base.hs @@ -361,7 +361,9 @@ -- |An expression that didn't typecheck during compile time was called. -- This is only possible with -fdefer-type-errors. The @String@ gives -- details about the failed type check. -data TypeError = TypeError String +-- +-- @since 4.9.0.0 +newtype TypeError = TypeError String instance Show TypeError where showsPrec _ (TypeError err) = showString err diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -91,6 +91,9 @@ precision: `log1p`, `expm1`, `log1pexp` and `log1mexp`. These are not available from `Prelude`, but the full class is exported from `Numeric`. + * New `Control.Exception.TypeError` datatype, which is thrown when an + expression fails to typecheck when run using `-fdefer-type-errors` (#10284) + ### New instances * `Alt`, `Dual`, `First`, `Last`, `Product`, and `Sum` now have `Data`,