summaryrefslogtreecommitdiff
path: root/compiler/GHC/Builtin/Types/Prim.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Builtin/Types/Prim.hs')
-rw-r--r--compiler/GHC/Builtin/Types/Prim.hs15
1 files changed, 13 insertions, 2 deletions
diff --git a/compiler/GHC/Builtin/Types/Prim.hs b/compiler/GHC/Builtin/Types/Prim.hs
index 29bb386001..115c76516d 100644
--- a/compiler/GHC/Builtin/Types/Prim.hs
+++ b/compiler/GHC/Builtin/Types/Prim.hs
@@ -35,7 +35,7 @@ module GHC.Builtin.Types.Prim(
tYPETyCon, tYPETyConName,
-- Kinds
- tYPE, primRepToRuntimeRep,
+ tYPE, primRepToRuntimeRep, primRepsToRuntimeRep,
functionWithMultiplicity,
funTyCon, funTyConName,
@@ -587,7 +587,7 @@ pcPrimTyCon name roles rep
-- Defined here to avoid (more) module loops
primRepToRuntimeRep :: PrimRep -> Type
primRepToRuntimeRep rep = case rep of
- VoidRep -> TyConApp tupleRepDataConTyCon [mkPromotedListTy runtimeRepTy []]
+ VoidRep -> mkTupleRep []
LiftedRep -> liftedRepTy
UnliftedRep -> unliftedRepTy
IntRep -> intRepDataConTy
@@ -626,6 +626,17 @@ primRepToRuntimeRep rep = case rep of
FloatElemRep -> floatElemRepDataConTy
DoubleElemRep -> doubleElemRepDataConTy
+-- | Given a list of types representing 'RuntimeRep's @reps@, construct
+-- @'TupleRep' reps@.
+mkTupleRep :: [Type] -> Type
+mkTupleRep reps = TyConApp tupleRepDataConTyCon [mkPromotedListTy runtimeRepTy reps]
+
+-- | Convert a list of 'PrimRep's to a 'Type' of kind RuntimeRep
+-- Defined here to avoid (more) module loops
+primRepsToRuntimeRep :: [PrimRep] -> Type
+primRepsToRuntimeRep [rep] = primRepToRuntimeRep rep
+primRepsToRuntimeRep reps = mkTupleRep $ map primRepToRuntimeRep reps
+
pcPrimTyCon0 :: Name -> PrimRep -> TyCon
pcPrimTyCon0 name rep
= pcPrimTyCon name [] rep