summaryrefslogtreecommitdiff
path: root/libraries/ghc-prim/GHC
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-02-02 10:06:11 -0500
committerBen Gamari <ben@smart-cactus.org>2021-03-07 17:01:40 -0500
commit3e082f8ff5ea2f42c5e6430094683b26b5818fb8 (patch)
tree4c85427ff40740b654cf1911a20a3a478a9fb754 /libraries/ghc-prim/GHC
parentcf65cf16c89414273c4f6b2d090d4b2fffb90759 (diff)
downloadhaskell-3e082f8ff5ea2f42c5e6430094683b26b5818fb8.tar.gz
Implement BoxedRep proposalwip/boxed-rep
This implements the BoxedRep proposal, refactoring the `RuntimeRep` hierarchy from: ```haskell data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ... ``` to ```haskell data RuntimeRep = BoxedRep Levity | ... data Levity = Lifted | Unlifted ``` Updates binary, haddock submodules. Closes #17526. Metric Increase: T12545
Diffstat (limited to 'libraries/ghc-prim/GHC')
-rw-r--r--libraries/ghc-prim/GHC/Types.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/libraries/ghc-prim/GHC/Types.hs b/libraries/ghc-prim/GHC/Types.hs
index f558619ac1..59edeec8af 100644
--- a/libraries/ghc-prim/GHC/Types.hs
+++ b/libraries/ghc-prim/GHC/Types.hs
@@ -33,7 +33,9 @@ module GHC.Types (
Symbol,
Any,
type (~~), Coercible,
- TYPE, RuntimeRep(..), Type, Constraint,
+ TYPE, Levity(..), RuntimeRep(..),
+ LiftedRep, UnliftedRep,
+ Type, UnliftedType, Constraint,
-- The historical type * should ideally be written as
-- `type *`, without the parentheses. But that's a true
-- pain to parse, and for little gain.
@@ -85,8 +87,17 @@ type (->) = FUN 'Many
-- | The kind of constraints, like @Show a@
data Constraint
+-- | The runtime representation of lifted types.
+type LiftedRep = 'BoxedRep 'Lifted
+
+-- | The runtime representation of unlifted types.
+type UnliftedRep = 'BoxedRep 'Unlifted
+
-- | The kind of types with lifted values. For example @Int :: Type@.
-type Type = TYPE 'LiftedRep
+type Type = TYPE LiftedRep
+
+-- | The kind of types with unlifted values. For example @Int# :: UnliftedType@.
+type UnliftedType = TYPE UnliftedRep
data Multiplicity = Many | One
@@ -410,6 +421,8 @@ data SPEC = SPEC | SPEC2
* *
********************************************************************* -}
+-- | Whether a boxed type is lifted or unlifted.
+data Levity = Lifted | Unlifted
-- | GHC maintains a property that the kind of all inhabited types
-- (as distinct from type constructors or type-level data) tells us
@@ -425,8 +438,7 @@ data SPEC = SPEC | SPEC2
data RuntimeRep = VecRep VecCount VecElem -- ^ a SIMD vector type
| TupleRep [RuntimeRep] -- ^ An unboxed tuple of the given reps
| SumRep [RuntimeRep] -- ^ An unboxed sum of the given reps
- | LiftedRep -- ^ lifted; represented by a pointer
- | UnliftedRep -- ^ unlifted; represented by a pointer
+ | BoxedRep Levity -- ^ boxed; represented by a pointer
| IntRep -- ^ signed, word-sized value
| Int8Rep -- ^ signed, 8-bit value
| Int16Rep -- ^ signed, 16-bit value
@@ -444,6 +456,7 @@ data RuntimeRep = VecRep VecCount VecElem -- ^ a SIMD vector type
-- RuntimeRep is intimately tied to TyCon.RuntimeRep (in GHC proper). See
-- Note [RuntimeRep and PrimRep] in RepType.
-- See also Note [Wiring in RuntimeRep] in GHC.Builtin.Types
+-- See also Note [TYPE and RuntimeRep] in GHC.Builtin.Type.Prim
-- | Length of a SIMD vector type
data VecCount = Vec2