module DDC.Core.Flow.Prim.TyConPrim
( kindPrimTyCon
, tVoid
, tBool
, tNat
, tInt
, tFloat
, tWord
, tVec)
where
import DDC.Core.Flow.Prim.Base
import DDC.Core.Compounds.Simple
import DDC.Core.Exp.Simple
kindPrimTyCon :: PrimTyCon -> Kind Name
kindPrimTyCon tc
= case tc of
PrimTyConVoid -> kData
PrimTyConPtr -> (kRegion `kFun` kData `kFun` kData)
PrimTyConAddr -> kData
PrimTyConBool -> kData
PrimTyConNat -> kData
PrimTyConInt -> kData
PrimTyConWord _ -> kData
PrimTyConFloat _ -> kData
PrimTyConTag -> kData
PrimTyConVec _ -> kData `kFun` kData
PrimTyConString -> kData
tVoid = TCon (TyConBound (UPrim (NamePrimTyCon PrimTyConVoid) kData) kData)
tBool :: Type Name
tBool = TCon (TyConBound (UPrim (NamePrimTyCon PrimTyConBool) kData) kData)
tNat :: Type Name
tNat = TCon (TyConBound (UPrim (NamePrimTyCon PrimTyConNat) kData) kData)
tInt :: Type Name
tInt = TCon (TyConBound (UPrim (NamePrimTyCon PrimTyConInt) kData) kData)
tFloat :: Int -> Type Name
tFloat bits
= TCon (TyConBound (UPrim (NamePrimTyCon (PrimTyConFloat bits)) kData) kData)
tWord :: Int -> Type Name
tWord bits
= TCon (TyConBound (UPrim (NamePrimTyCon (PrimTyConWord bits)) kData) kData)
tVec :: Int -> Type Name -> Type Name
tVec n tA = TApp (tConPrimTyCon (PrimTyConVec n)) tA
tConPrimTyCon :: PrimTyCon -> Type Name
tConPrimTyCon tcp
= let k = kindPrimTyCon tcp
u = UPrim (NamePrimTyCon tcp) k
tc = TyConBound u k
in TCon tc