diff options
author | Andrew Martin <andrew.thaddeus@gmail.com> | 2020-10-07 15:45:30 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-12-14 18:48:51 -0500 |
commit | 6c2eb2232b39ff4720fda0a4a009fb6afbc9dcea (patch) | |
tree | 0a19d6cece0d63aadcfa6e014171a5baeaf4c167 /docs/users_guide | |
parent | dad87210efffce9cfc2d17dc088a71d9dea14535 (diff) | |
download | haskell-6c2eb2232b39ff4720fda0a4a009fb6afbc9dcea.tar.gz |
Implement BoxedRep proposal
This implements the BoxedRep proposal, refacoring the `RuntimeRep`
hierarchy from:
```haskell
data RuntimeRep = LiftedPtrRep | UnliftedPtrRep | ...
```
to
```haskell
data RuntimeRep = BoxedRep Levity | ...
data Levity = Lifted | Unlifted
```
Closes #17526.
Diffstat (limited to 'docs/users_guide')
-rw-r--r-- | docs/users_guide/9.2.1-notes.rst | 6 | ||||
-rw-r--r-- | docs/users_guide/exts/levity_polymorphism.rst | 20 | ||||
-rw-r--r-- | docs/users_guide/exts/typed_holes.rst | 2 |
3 files changed, 19 insertions, 9 deletions
diff --git a/docs/users_guide/9.2.1-notes.rst b/docs/users_guide/9.2.1-notes.rst index 283615b7a4..bfa8283092 100644 --- a/docs/users_guide/9.2.1-notes.rst +++ b/docs/users_guide/9.2.1-notes.rst @@ -13,6 +13,12 @@ Language <https://www.microsoft.com/en-us/research/publication/a-quick-look-at-impredicativity/>`__ (Serrano et al, ICFP 2020). More information here: :ref:`impredicative-polymorphism`. This replaces the old (undefined, flaky) behaviour of the :extension:`ImpredicativeTypes` extension. +* The first stage of the `Pointer Rep Proposal`_ has been implemented. All + boxed types, both lifted and unlifted, now have representation kinds of + the shape ``BoxedRep r``. Code that references ``LiftedRep`` and ``UnliftedRep`` + will need to be updated. + +.. _Pointer Rep Proposal: https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0203-pointer-rep.rst * Kind inference for data/newtype instance declarations is slightly more restrictive than before. See the user manual :ref:`kind-inference-data-family-instances`. diff --git a/docs/users_guide/exts/levity_polymorphism.rst b/docs/users_guide/exts/levity_polymorphism.rst index a65f878b41..80a544e54b 100644 --- a/docs/users_guide/exts/levity_polymorphism.rst +++ b/docs/users_guide/exts/levity_polymorphism.rst @@ -13,21 +13,25 @@ Here are the key definitions, all available from ``GHC.Exts``: :: TYPE :: RuntimeRep -> Type -- highly magical, built into GHC - data RuntimeRep = LiftedRep -- for things like `Int` - | UnliftedRep -- for things like `Array#` - | IntRep -- for `Int#` + data Levity = Lifted -- for things like `Int` + | Unlifted -- for things like `Array#` + + data RuntimeRep = BoxedRep Levity -- for anything represented by a GC-managed pointer + | IntRep -- for `Int#` | TupleRep [RuntimeRep] -- unboxed tuples, indexed by the representations of the elements | SumRep [RuntimeRep] -- unboxed sums, indexed by the representations of the disjuncts | ... + type LiftedRep = BoxedRep Lifted + type Type = TYPE LiftedRep -- Type is just an ordinary type synonym The idea is that we have a new fundamental type constant ``TYPE``, which is parameterised by a ``RuntimeRep``. We thus get ``Int# :: TYPE 'IntRep`` -and ``Bool :: TYPE 'LiftedRep``. Anything with a type of the form +and ``Bool :: TYPE LiftedRep``. Anything with a type of the form ``TYPE x`` can appear to either side of a function arrow ``->``. We can thus say that ``->`` has type -``TYPE r1 -> TYPE r2 -> TYPE 'LiftedRep``. The result is always lifted +``TYPE r1 -> TYPE r2 -> TYPE LiftedRep``. The result is always lifted because all functions are lifted in GHC. .. _levity-polymorphic-restrictions: @@ -102,13 +106,13 @@ Printing levity-polymorphic types :category: verbosity Print ``RuntimeRep`` parameters as they appear; otherwise, they are - defaulted to ``'LiftedRep``. + defaulted to ``LiftedRep``. Most GHC users will not need to worry about levity polymorphism or unboxed types. For these users, seeing the levity polymorphism in the type of ``$`` is unhelpful. And thus, by default, it is suppressed, -by supposing all type variables of type ``RuntimeRep`` to be ``'LiftedRep`` -when printing, and printing ``TYPE 'LiftedRep`` as ``Type`` (or ``*`` when +by supposing all type variables of type ``RuntimeRep`` to be ``LiftedRep`` +when printing, and printing ``TYPE LiftedRep`` as ``Type`` (or ``*`` when :extension:`StarIsType` is on). Should you wish to see levity polymorphism in your types, enable diff --git a/docs/users_guide/exts/typed_holes.rst b/docs/users_guide/exts/typed_holes.rst index 170824ee4f..4fded59ae2 100644 --- a/docs/users_guide/exts/typed_holes.rst +++ b/docs/users_guide/exts/typed_holes.rst @@ -443,7 +443,7 @@ it will additionally offer up a list of refinement hole fits, in this case: :: with const @Integer @[Integer] where const :: forall a b. a -> b -> a ($) (_ :: [Integer] -> Integer) - with ($) @'GHC.Types.LiftedRep @[Integer] @Integer + with ($) @GHC.Types.LiftedRep @[Integer] @Integer where ($) :: forall a b. (a -> b) -> a -> b fail (_ :: String) with fail @((->) [Integer]) @Integer |