summaryrefslogtreecommitdiff
path: root/docs/users_guide/9.4.1-notes.rst
blob: 73901ad8bea2bb05123eb35827c041330f2d9317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
.. _release-9-4-1:

Version 9.4.1
==============

``base`` library
~~~~~~~~~~~~~~~~

- ``GHC.Exts.magicDict`` has been renamed to ``withDict`` and given a more
  specific type: ::

        withDict :: forall {rr :: RuntimeRep} st dt (r :: TYPE rr). st -> (dt => r) -> r

  Unlike ``magicDict``, ``withDict`` can be used without defining an
  intermediate data type. For example, the ``withTypeable`` function from the
  ``Data.Typeable`` module can now be defined as: ::

        withTypeable :: forall k (a :: k) rep (r :: TYPE rep). ()
                     => TypeRep a -> (Typeable a => r) -> r
        withTypeable rep k = withDict @(TypeRep a) @(Typeable a) rep k

  Note that the explicit type applications are required, as the call to
  ``withDict`` would be ambiguous otherwise.

``ghc-prim`` library
~~~~~~~~~~~~~~~~~~~~

- ``GHC.Exts.mkWeak#``, ``GHC.Exts.mkWeakNoFinalizer#``, ``GHC.Exts.touch#``
  and ``GHC.Exts.keepAlive#`` are now levity-polymorphic instead of
  representation-polymorphic. For instance: ::

        mkWeakNoFinalizer#
          :: forall {l :: Levity} (a :: TYPE (BoxedRep l)) (b :: Type)
          .  a -> b -> State# RealWorld -> (# State# RealWorld, Weak# b #)

  That is, the type signature now quantifies over a variable of type ``GHC.Exts.Levity``
  instead of ``GHC.Exts.RuntimeRep``. In addition, this variable is now inferred,
  instead of specified, meaning that it is no longer eligible for visible type application.

- The ``GHC.Exts.RuntimeRep`` parameter to ``GHC.Exts.raise#`` is now inferred: ::

        raise# :: forall (a :: Type) {r :: RuntimeRep} (b :: TYPE r). a -> b