GADTs).
\begin{code}
-tcFamInstDecl :: LTyClDecl Name -> TcM (Maybe TyThing) -- Nothing if error
+tcFamInstDecl :: LTyClDecl Name -> TcM TyThing
tcFamInstDecl (L loc decl)
= -- Prime error recovery, set source location
- recoverM (return Nothing) $
setSrcSpan loc $
tcAddDeclCtxt decl $
do { -- type families require -XTypeFamilies and can't be in an
; tc <- tcFamInstDecl1 decl
; checkValidTyCon tc -- Remember to check validity;
-- no recursion to worry about here
- ; return (Just (ATyCon tc))
- }
+ ; return (ATyCon tc) }
tcFamInstDecl1 :: TyClDecl Name -> TcM TyCon
-- E.g. data T a b c where
-- MkT :: forall x y z. T (x,y) z z
-- Then we generate
- -- ([a,z,c], [x,y], [a:=:(x,y), c:=:z], T)
+ -- ([a,z,c], [x,y], [a~(x,y), c~z], T)
= do { (dc_tycon, res_tys) <- tcLHsConResTy res_ty
= setSrcSpan (srcLocSpan (getSrcLoc con)) $
addErrCtxt (dataConCtxt con) $
do { checkTc (dataConTyCon con == tc) (badDataConTyCon con)
- ; checkValidType ctxt (dataConUserType con)
; checkValidMonoType (dataConOrigResTy con)
-- Disallow MkT :: T (forall a. a->a)
-- Reason: it's really the argument of an equality constraint
+ ; checkValidType ctxt (dataConUserType con)
; when (isNewTyCon tc) (checkNewDataCon con)
}
where