summaryrefslogtreecommitdiff
path: root/docs/users_guide
diff options
context:
space:
mode:
authorRyan Scott <ryan.gl.scott@gmail.com>2021-04-13 19:50:50 -0400
committerRyan Scott <ryan.gl.scott@gmail.com>2021-04-14 08:41:32 -0400
commit78369f354faf4667d576d9762c6a85dd753fc6da (patch)
treef0980e72efb2898386b84dfb33c2a46763cf9843 /docs/users_guide
parente63cdccabe0bfbd73a475c669404b9604cf859f5 (diff)
downloadhaskell-wip/T16646-take-two.tar.gz
Redesign the type of magicDictwip/T16646-take-two
This gives a more precise type signature to `magicDict` as proposed in #16646. In addition to making it more type safe: * This allows the `magicDict` constant-folding rule to apply to classes with multiple type arguments, such as `Typeable @k a`. This means that `withTypeable` can now be implemented in terms of `magicDict`. * Moreover, since the constant-folding rule no longer needs to case on the structure of the expression passed as an argument to `magicDict`, it no longer cares about the presence or absence of `Tick`s. In effect, this obsoletes the fix for #19667. The new `T16646` test case demonstrates the new version of `magicDict` in action, both in terms of `base` functions defined in terms of `magicDict` as well as in terms of functions from the `reflection` and `singletons` libraries. This fixes #16646. By adding more tests for `magicDict`, this also fixes #19673 as a side effect.
Diffstat (limited to 'docs/users_guide')
-rw-r--r--docs/users_guide/9.4.1-notes.rst22
-rw-r--r--docs/users_guide/release-notes.rst1
2 files changed, 23 insertions, 0 deletions
diff --git a/docs/users_guide/9.4.1-notes.rst b/docs/users_guide/9.4.1-notes.rst
new file mode 100644
index 0000000000..188593872e
--- /dev/null
+++ b/docs/users_guide/9.4.1-notes.rst
@@ -0,0 +1,22 @@
+.. _release-9-4-1:
+
+Version 9.4.1
+==============
+
+``base`` library
+~~~~~~~~~~~~~~~~
+
+- ``GHC.Exts.magicDict`` now has the type: ::
+
+ magicDict :: forall {rr :: RuntimeRep} dt st (r :: TYPE rr). (dt => r) -> st -> r
+
+ ``magicDict`` can now 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 = magicDict @(Typeable a) k rep
+
+ Note that the explicit type application is required, as the call to
+ ``magicDict`` would be ambiguous otherwise.
diff --git a/docs/users_guide/release-notes.rst b/docs/users_guide/release-notes.rst
index 92d4277a67..8b1313d8fe 100644
--- a/docs/users_guide/release-notes.rst
+++ b/docs/users_guide/release-notes.rst
@@ -6,3 +6,4 @@ Release notes
9.0.1-notes
9.2.1-notes
+ 9.4.1-notes