diff options
author | Krzysztof Gogolewski <krzysztof.gogolewski@tweag.io> | 2022-07-13 19:06:18 +0200 |
---|---|---|
committer | Douglas Wilson <douglas.wilson@gmail.com> | 2022-07-28 10:31:44 +0100 |
commit | 388ec68fad42e8beac537bd5f5cd8fff782a003b (patch) | |
tree | b8cc4ffe5a062aac52e3c73222f3f2c75b198d6b | |
parent | 9187b984d602dc38050801f11ec31dc56085f029 (diff) | |
download | haskell-388ec68fad42e8beac537bd5f5cd8fff782a003b.tar.gz |
Update 9.4 release notes regarding withDict
The type was changed in !8249 and this was backported to 9.4.
(cherry picked from commit b0d98619a3bc01246bd5b23e6d4afb340df46150)
-rw-r--r-- | docs/users_guide/9.4.1-notes.rst | 19 | ||||
-rw-r--r-- | libraries/base/changelog.md | 14 |
2 files changed, 18 insertions, 15 deletions
diff --git a/docs/users_guide/9.4.1-notes.rst b/docs/users_guide/9.4.1-notes.rst index 45b65ce32d..7a1a4ebdf4 100644 --- a/docs/users_guide/9.4.1-notes.rst +++ b/docs/users_guide/9.4.1-notes.rst @@ -243,15 +243,18 @@ Runtime system - There's a new special function ``withDict`` in ``GHC.Exts``: :: - withDict :: forall {rr :: RuntimeRep} st dt (r :: TYPE rr). st -> (dt => r) -> r + withDict :: forall {rr :: RuntimeRep} cls meth (r :: TYPE rr). WithDict cls meth => meth -> (cls => r) -> r - where ``dt`` must be a class containing exactly one method, whose type - must be ``st``. This function converts ``st`` to a type class dictionary. + where ``cls`` must be a class containing exactly one method, whose type + must be ``meth``. This requirement is enforced by the constraint + ``WithDict cls meth``. + + This function converts ``meth`` to a type class dictionary. It removes the need for ``unsafeCoerce`` in implementation of reflection libraries. It should be used with care, because it can introduce incoherent instances. -- See the the ``base`` library's ``changelog.md`` for a full accounting. +- See the ``base`` library's ``changelog.md`` for a full accounting. ``ghc-prim`` library ~~~~~~~~~~~~~~~~~~~~ @@ -372,7 +375,7 @@ Runtime system - ``maskAsyncExceptions#``, ``maskUninterruptible#``, ``unmaskAsyncExceptions#``. Note in particular that ``raise#`` is now both representation-polymorphic - (with an inferred `RuntimeRep` argument) and levity-polymorphic, with type: :: + (with an inferred ``RuntimeRep`` argument) and levity-polymorphic, with type: :: raise# :: forall {l :: Levity} {r :: RuntimeRep} (a :: TYPE (BoxedRep l)) @@ -442,12 +445,12 @@ Runtime system datatype, to track the presence of a promotion tick. Plugins which manipulate the Haskell AST will need to take this change into account. -- Removed `lookupOrigIO` in favor of `lookupNameCache` +- Removed ``lookupOrigIO`` in favor of ``lookupNameCache``. -- Added a new `thNameToGhcNameIO` function that plugins can use outside the `CoreM` monad. +- Added a new ``thNameToGhcNameIO`` function that plugins can use outside the ``CoreM`` monad. ``ghc-heap`` library -~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~~~ - The ``link`` field of ``GHC.Exts.Heap.WeakClosure`` has been replaced with a ``weakLink`` field which is ``Nothing`` if and only if ``link`` would have diff --git a/libraries/base/changelog.md b/libraries/base/changelog.md index 15786e9b83..442965797f 100644 --- a/libraries/base/changelog.md +++ b/libraries/base/changelog.md @@ -50,24 +50,24 @@ * There's a new special function ``withDict`` in ``GHC.Exts``: :: - withDict :: forall {rr :: RuntimeRep} st dt (r :: TYPE rr). st -> (dt => r) -> r + withDict :: forall {rr :: RuntimeRep} cls meth (r :: TYPE rr). WithDict cls meth => meth -> (cls => r) -> r - where ``dt`` must be a class containing exactly one method, whose type - must be ``st``. + where ``cls`` must be a class containing exactly one method, whose type + must be ``meth``. - This function converts ``st`` to a type class dictionary. + This function converts ``meth`` to a type class dictionary. It removes the need for ``unsafeCoerce`` in implementation of reflection libraries. It should be used with care, because it can introduce incoherent instances. For example, the ``withTypeable`` function from the - ``Data.Typeable`` module can now be defined as: :: + ``Type.Reflection`` 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 + withTypeable rep k = withDict @(Typeable a) rep k - Note that the explicit type applications are required, as the call to + Note that the explicit type application is required, as the call to ``withDict`` would be ambiguous otherwise. This replaces the old ``GHC.Exts.magicDict``, which required |