module DDC.Type.Predicates
( isBot
, isAtomT
, isDataKind
, isRegionKind
, isEffectKind
, isClosureKind
, isWitnessKind
, isAlgDataType)
where
import DDC.Type.Exp
import DDC.Type.Compounds
import qualified DDC.Type.Sum as T
isBot :: Type n -> Bool
isBot tt
| TSum ss <- tt
, [] <- T.toList ss
= True
| otherwise = False
isAtomT :: Type n -> Bool
isAtomT tt
= case tt of
TVar{} -> True
TCon{} -> True
_ -> isBot tt
isDataKind :: Kind n -> Bool
isDataKind tt
= case tt of
TCon (TyConKind KiConData) -> True
_ -> False
isRegionKind :: Region n -> Bool
isRegionKind tt
= case tt of
TCon (TyConKind KiConRegion) -> True
_ -> False
isEffectKind :: Kind n -> Bool
isEffectKind tt
= case tt of
TCon (TyConKind KiConEffect) -> True
_ -> False
isClosureKind :: Kind n -> Bool
isClosureKind tt
= case tt of
TCon (TyConKind KiConClosure) -> True
_ -> False
isWitnessKind :: Kind n -> Bool
isWitnessKind tt
= case tt of
TCon (TyConKind KiConWitness) -> True
_ -> False
isAlgDataType :: Eq n => Type n -> Bool
isAlgDataType tt
| Just (tc, _) <- takeTyConApps tt
, TyConBound u <- tc
= takeResultKind (typeOfBound u) == kData
| otherwise
= False