summaryrefslogtreecommitdiff
path: root/compiler/GHC/Core
diff options
context:
space:
mode:
authorsheaf <sam.derbyshire@gmail.com>2023-04-29 18:59:10 +0200
committersheaf <sam.derbyshire@gmail.com>2023-04-29 20:23:06 +0200
commit57277662989b97dbf5ddc034d6c41ce39ab674ab (patch)
tree7d9fe1c4cb95a8bcf82490c354b5df0e9ab9037c /compiler/GHC/Core
parent4eaf2c2a7682fa9933261f5eb25da9e2333c9608 (diff)
downloadhaskell-57277662989b97dbf5ddc034d6c41ce39ab674ab.tar.gz
Add the Unsatisfiable class
This commit implements GHC proposal #433, adding the Unsatisfiable class to the GHC.TypeError module. This provides an alternative to TypeError for which error reporting is more predictable: we report it when we are reporting unsolved Wanted constraints. Fixes #14983 #16249 #16906 #18310 #20835
Diffstat (limited to 'compiler/GHC/Core')
-rw-r--r--compiler/GHC/Core/Type.hs11
1 files changed, 7 insertions, 4 deletions
diff --git a/compiler/GHC/Core/Type.hs b/compiler/GHC/Core/Type.hs
index 40fa1ea2df..86f483abca 100644
--- a/compiler/GHC/Core/Type.hs
+++ b/compiler/GHC/Core/Type.hs
@@ -76,6 +76,7 @@ module GHC.Core.Type (
mkCastTy, mkCoercionTy, splitCastTy_maybe,
+ ErrorMsgType,
userTypeError_maybe, pprUserTypeErrorTy,
coAxNthLHS,
@@ -1229,9 +1230,12 @@ isLitTy ty
| LitTy l <- coreFullView ty = Just l
| otherwise = Nothing
+-- | A type of kind 'ErrorMessage' (from the 'GHC.TypeError' module).
+type ErrorMsgType = Type
+
-- | Is this type a custom user error?
--- If so, give us the kind and the error message.
-userTypeError_maybe :: Type -> Maybe Type
+-- If so, give us the error message.
+userTypeError_maybe :: Type -> Maybe ErrorMsgType
userTypeError_maybe t
= do { (tc, _kind : msg : _) <- splitTyConApp_maybe t
-- There may be more than 2 arguments, if the type error is
@@ -1241,7 +1245,7 @@ userTypeError_maybe t
; return msg }
-- | Render a type corresponding to a user type error into a SDoc.
-pprUserTypeErrorTy :: Type -> SDoc
+pprUserTypeErrorTy :: ErrorMsgType -> SDoc
pprUserTypeErrorTy ty =
case splitTyConApp_maybe ty of
@@ -1267,7 +1271,6 @@ pprUserTypeErrorTy ty =
-- An unevaluated type function
_ -> ppr ty
-
{- *********************************************************************
* *
FunTy