Commit 6ea24af9 authored by Iavor S. Diatchki's avatar Iavor S. Diatchki
Browse files

Handle over-applied custom type errors too.

Consider

    type family F :: Type -> Type where
       F = TypeError (Text "Error")

Now, if we see something like `F Int` we should still report the custom
type error.
parent c3f92464
......@@ -1733,9 +1733,9 @@ isTypeHoleCt (CHoleCan { cc_hole = TypeHole }) = True
isTypeHoleCt _ = False
-- | The following constraints are considered to be a custom type error:
-- 1. TypeError msg
-- 2. TypeError msg ~ Something (and the other way around)
-- 3. C (TypeError msg) (for any parameter of class constraint)
-- 1. TypeError msg a b c
-- 2. TypeError msg a b c ~ Something (and the other way around)
-- 4. C (TypeError msg a b c) (for any parameter of class constraint)
getUserTypeErrorMsg :: Ct -> Maybe Type
getUserTypeErrorMsg ct
| Just (_,t1,t2) <- getEqPredTys_maybe ctT = oneOf [t1,t2]
......
......@@ -707,7 +707,10 @@ isStrLitTy _ = Nothing
-- If so, give us the kind and the error message.
userTypeError_maybe :: Type -> Maybe Type
userTypeError_maybe t
= do { (tc, [_kind, msg]) <- splitTyConApp_maybe t
= do { (tc, _kind : msg : _) <- splitTyConApp_maybe t
-- There may be more than 2 arguments, if the type error is
-- used as a type constructor (e.g. at kind `Type -> Type`).
; guard (tyConName tc == errorMessageTypeErrorFamName)
; return msg }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment