+ | HsNumTy Integer -- Generics only
+
+ -- these next two are only used in interfaces
+ | HsPredTy (HsPred name)
+
+ | HsKindSig (HsType name) -- (ty :: kind)
+ Kind -- A type with a kind signature
+
+
+data HsTyOp name = HsArrow | HsTyOp name
+ -- Function arrows from *source* get read in as HsOpTy t1 HsArrow t2
+ -- But when we generate or parse interface files, we use HsFunTy.
+ -- This keeps interfaces a bit smaller, because there are a lot of arrows
+
+-----------------------
+data HsTupCon = HsTupCon Boxity Arity
+
+instance Eq HsTupCon where
+ (HsTupCon b1 a1) == (HsTupCon b2 a2) = b1==b2 && a1==a2
+
+mkHsTupCon :: NameSpace -> Boxity -> [a] -> HsTupCon
+mkHsTupCon space boxity args = HsTupCon boxity (length args)
+
+hsTupParens :: HsTupCon -> SDoc -> SDoc
+hsTupParens (HsTupCon b _) p = tupleParens b p
+
+-----------------------
+-- Combine adjacent for-alls.
+-- The following awkward situation can happen otherwise:
+-- f :: forall a. ((Num a) => Int)
+-- might generate HsForAll (Just [a]) [] (HsForAll Nothing [Num a] t)
+-- Then a isn't discovered as ambiguous, and we abstract the AbsBinds wrt []
+-- but the export list abstracts f wrt [a]. Disaster.
+--
+-- A valid type must have one for-all at the top of the type, or of the fn arg types
+
+mkHsForAllTy mtvs [] ty = mk_forall_ty mtvs ty
+mkHsForAllTy mtvs ctxt ty = HsForAllTy mtvs ctxt ty
+
+-- mk_forall_ty makes a pure for-all type (no context)
+mk_forall_ty (Just []) ty = ty -- Explicit for-all with no tyvars
+mk_forall_ty mtvs1 (HsParTy ty) = mk_forall_ty mtvs1 ty
+mk_forall_ty mtvs1 (HsForAllTy mtvs2 ctxt ty) = mkHsForAllTy (mtvs1 `plus` mtvs2) ctxt ty
+mk_forall_ty mtvs1 ty = HsForAllTy mtvs1 [] ty
+
+mtvs1 `plus` Nothing = mtvs1
+Nothing `plus` mtvs2 = mtvs2
+(Just tvs1) `plus` (Just tvs2) = Just (tvs1 ++ tvs2)
+
+mkHsDictTy cls tys = HsPredTy (HsClassP cls tys)
+mkHsIParamTy v ty = HsPredTy (HsIParam v ty)
+
+data HsTyVarBndr name
+ = UserTyVar name
+ | IfaceTyVar name Kind