+isFunTyCon :: TyCon -> Bool
+isFunTyCon (FunTyCon {}) = True
+isFunTyCon _ = False
+
+isAbstractTyCon :: TyCon -> Bool
+isAbstractTyCon (AlgTyCon { algRhs = AbstractTyCon }) = True
+isAbstractTyCon _ = False
+
+isPrimTyCon :: TyCon -> Bool
+isPrimTyCon (PrimTyCon {}) = True
+isPrimTyCon _ = False
+
+isUnLiftedTyCon :: TyCon -> Bool
+isUnLiftedTyCon (PrimTyCon {isUnLifted = is_unlifted}) = is_unlifted
+isUnLiftedTyCon (TupleTyCon {tyConBoxed = boxity}) = not (isBoxed boxity)
+isUnLiftedTyCon _ = False
+
+-- isAlgTyCon returns True for both @data@ and @newtype@
+isAlgTyCon :: TyCon -> Bool
+isAlgTyCon (AlgTyCon {}) = True
+isAlgTyCon (TupleTyCon {}) = True
+isAlgTyCon other = False
+
+algTyConRhs :: TyCon -> AlgTyConRhs
+algTyConRhs (AlgTyCon {algRhs = rhs}) = rhs
+algTyConRhs (TupleTyCon {dataCon = dc}) = DataTyCon [dc] False
+
+isDataTyCon :: TyCon -> Bool
+-- isDataTyCon returns True for data types that are represented by
+-- heap-allocated constructors.
+-- These are srcutinised by Core-level @case@ expressions, and they
+-- get info tables allocated for them.
+-- True for all @data@ types
+-- False for newtypes
+-- unboxed tuples
+isDataTyCon (AlgTyCon {algRhs = rhs})
+ = case rhs of
+ DataTyCon _ _ -> True
+ NewTyCon _ _ _ -> False
+ AbstractTyCon -> panic "isDataTyCon"
+
+isDataTyCon (TupleTyCon {tyConBoxed = boxity}) = isBoxed boxity
+isDataTyCon other = False
+
+isNewTyCon :: TyCon -> Bool
+isNewTyCon (AlgTyCon {algRhs = NewTyCon _ _ _}) = True
+isNewTyCon other = False
+
+isProductTyCon :: TyCon -> Bool
+-- A "product" tycon
+-- has *one* constructor,
+-- is *not* existential
+-- but
+-- may be DataType or NewType,
+-- may be unboxed or not,
+-- may be recursive or not
+isProductTyCon tc@(AlgTyCon {}) = case algRhs tc of
+ DataTyCon [data_con] _ -> not (isExistentialDataCon data_con)
+ NewTyCon _ _ _ -> True
+ other -> False
+isProductTyCon (TupleTyCon {}) = True
+isProductTyCon other = False
+
+isSynTyCon :: TyCon -> Bool
+isSynTyCon (SynTyCon {}) = True
+isSynTyCon _ = False
+
+isEnumerationTyCon :: TyCon -> Bool
+isEnumerationTyCon (AlgTyCon {algRhs = DataTyCon _ is_enum}) = is_enum
+isEnumerationTyCon other = False
+
+isTupleTyCon :: TyCon -> Bool
+-- The unit tycon didn't used to be classed as a tuple tycon
+-- but I thought that was silly so I've undone it
+-- If it can't be for some reason, it should be a AlgTyCon
+isTupleTyCon (TupleTyCon {}) = True
+isTupleTyCon other = False
+
+isUnboxedTupleTyCon :: TyCon -> Bool
+isUnboxedTupleTyCon (TupleTyCon {tyConBoxed = boxity}) = not (isBoxed boxity)
+isUnboxedTupleTyCon other = False
+
+isBoxedTupleTyCon :: TyCon -> Bool
+isBoxedTupleTyCon (TupleTyCon {tyConBoxed = boxity}) = isBoxed boxity
+isBoxedTupleTyCon other = False
+
+tupleTyConBoxity tc = tyConBoxed tc
+
+isRecursiveTyCon :: TyCon -> Bool
+isRecursiveTyCon (AlgTyCon {algTyConRec = Recursive}) = True
+isRecursiveTyCon other = False
+
+isHiBootTyCon :: TyCon -> Bool
+-- Used for knot-tying in hi-boot files
+isHiBootTyCon (AlgTyCon {algRhs = AbstractTyCon}) = True
+isHiBootTyCon other = False
+
+isForeignTyCon :: TyCon -> Bool
+-- isForeignTyCon identifies foreign-imported type constructors
+isForeignTyCon (PrimTyCon {tyConExtName = Just _}) = True
+isForeignTyCon other = False