checkTyClHdr, -- LHsContext RdrName -> LHsType RdrName -> P (LHsContext RdrName, Located RdrName, [LHsTyVarBndr RdrName], [LHsType RdrName])
checkTyVars, -- [LHsType RdrName] -> Bool -> P ()
checkSynHdr, -- LHsType RdrName -> P (Located RdrName, [LHsTyVarBndr RdrName], Maybe [LHsType RdrName])
- checkTopTyClD, -- LTyClDecl RdrName -> P (HsDecl RdrName)
+ checkTopTypeD, -- LTyClDecl RdrName -> P (HsDecl RdrName)
checkInstType, -- HsType -> P HsType
checkPattern, -- HsExp -> P HsPat
checkPatterns, -- SrcLoc -> [HsExp] -> P [HsPat]
-- result. Eg, for
-- T Int [a]
-- we return
--- ('()', 'T', ['a'], Just ['Int', '[a]'])
+-- ('()', 'T', ['a'], ['Int', '[a]'])
checkTyClHdr (L l cxt) ty
= do (tc, tvs, parms) <- gol ty []
mapM_ chk_pred cxt
tvs' <- collects tvs ts
collect tvs' t
--- Wrap a toplevel type or class declaration into 'TyClDecl' after ensuring
--- that all type parameters are variables only (which is in contrast to
--- associated type declarations).
+-- Wrap a toplevel type or data declaration into 'TyClD' and ensure for
+-- data declarations that all type parameters are variables only (which is in
+-- contrast to type functions and associated type declarations).
--
-checkTopTyClD :: LTyClDecl RdrName -> P (HsDecl RdrName)
-checkTopTyClD (L _ d@TyData {tcdTyPats = Just typats}) =
+checkTopTypeD :: LTyClDecl RdrName -> P (HsDecl RdrName)
+checkTopTypeD (L _ d@TyData {tcdTyPats = Just typats}) =
do
+ -- `tcdTyPats' will only be of the form `Just typats' if `typats' contains
+ -- a non-variable pattern. We call `checkTyPats' instead of raising an
+ -- error straight away, as `checkTyPats' raises the error at the location
+ -- of that non-variable pattern.
+ --
checkTyVars typats False
- return $ TyClD d {tcdTyPats = Nothing}
-checkTopTyClD (L _ d) = return $ TyClD d
+ panic "checkTopTypeD: check on previous line should fail w/ a parse error"
+checkTopTypeD (L _ d) = return $ TyClD d
checkContext :: LHsType RdrName -> P (LHsContext RdrName)
checkContext (L l t)