+GADT constructor signatures
+
+\begin{code}
+tcLHsConSig :: LHsType Name
+ -> TcM ([TcTyVar], TcThetaType,
+ [HsBang], [TcType],
+ TyCon, [TcType])
+-- Take apart the type signature for a data constructor
+-- The difference is that there can be bangs at the top of
+-- the argument types, and kind-checking is the right place to check
+tcLHsConSig sig@(L span (HsForAllTy exp tv_names ctxt ty))
+ = setSrcSpan span $
+ addErrCtxt (gadtSigCtxt sig) $
+ tcTyVarBndrs tv_names $ \ tyvars ->
+ do { theta <- mappM dsHsLPred (unLoc ctxt)
+ ; (bangs, arg_tys, tc, res_tys) <- tc_con_sig_tau ty
+ ; return (tyvars, theta, bangs, arg_tys, tc, res_tys) }
+tcLHsConSig ty
+ = do { (bangs, arg_tys, tc, res_tys) <- tc_con_sig_tau ty
+ ; return ([], [], bangs, arg_tys, tc, res_tys) }
+
+--------
+tc_con_sig_tau (L _ (HsFunTy arg ty))
+ = do { (bangs, arg_tys, tc, res_tys) <- tc_con_sig_tau ty
+ ; arg_ty <- tcHsBangType arg
+ ; return (getBangStrictness arg : bangs,
+ arg_ty : arg_tys, tc, res_tys) }
+
+tc_con_sig_tau ty
+ = do { (tc, res_tys) <- tc_con_res ty []
+ ; return ([], [], tc, res_tys) }
+
+--------
+tc_con_res (L _ (HsAppTy fun res_ty)) res_tys
+ = do { res_ty' <- dsHsType res_ty
+ ; tc_con_res fun (res_ty' : res_tys) }
+
+tc_con_res ty@(L _ (HsTyVar name)) res_tys
+ = do { thing <- tcLookup name
+ ; case thing of
+ AGlobal (ATyCon tc) -> return (tc, res_tys)
+ other -> failWithTc (badGadtDecl ty)
+ }
+
+tc_con_res ty _ = failWithTc (badGadtDecl ty)
+
+gadtSigCtxt ty
+ = hang (ptext SLIT("In the signature of a data constructor:"))
+ 2 (ppr ty)
+badGadtDecl ty
+ = hang (ptext SLIT("Malformed constructor signature:"))
+ 2 (ppr ty)
+\end{code}