summaryrefslogtreecommitdiff
path: root/docs/users_guide/9.6.1-notes.rst
blob: 0f1d96575c7d5428475668c7c1c4a52fe3ef9d02 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
.. _release-9-6-1:

Version 9.6.1
==============


Language
~~~~~~~~

- Record updates for GADTs and other existential datatypes are now
  fully supported.

  For example: ::

    data D b where
      MkD :: { fld1 :: a -> a, fld2 :: a -> (), fld3 :: b } -> D b

    foo :: D b -> D b
    foo d = d { fld1 = id, fld2 = const () }

  In this example, we have an existential variable ``a``, and we update
  all fields whose type involves ``a`` at once, so the update is valid.

  A side-effect of this change is that GHC now rejects some record updates
  involving fields whose types contain type families (these record updates
  were previously erroneously accepted).

  Example: ::

    type family F a where
      F Int   = Char
      F Float = Char

    data T b = MkT { x :: [Int], y :: [F b] }

    emptyT :: forall b. T b
    emptyT = MkT [] []

    bar :: T Int
    bar = emptyT { x = [3] }

  In this example, we can't infer the type of ``emptyT`` in ``bar``: it could be
  ``T Int``, but it could also be ``T Float`` because the type family ``F``
  is not injective and ``T Float ~ T Int``. Indeed, the following typechecks ::

    baz :: T Int
    baz = case ( emptyT :: T Float ) of { MkT _ y -> MkT [3] y }

  This means that the type of ``emptyT`` is ambiguous in the definition
  of ``bar`` above, and thus GHC rejects the record update: ::

    Couldn't match type `F b0' with `Char'
    Expected: [F Int]
      Actual: [F b0]
    NB: ‘F’ is a non-injective type family
    The type variable ‘b0’ is ambiguous

  To fix these issues, add a type signature to the expression that the
  record update is applied to (``emptyT`` in the example above), or
  add an injectivity annotation to the type family in the case that
  the type family is in fact injective.

Compiler
~~~~~~~~

- The :extension:`TypeInType` is now marked as deprecated. Its meaning has been included 
  in :extension:`PolyKinds` and :extension:`DataKinds`.

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

- Exceptions thrown by weak pointer finalizers are now caught and reported
  via a global exception handler. By default this handler reports the error
  to ``stderr`` although this can be changed using
  ``GHC.Weak.Finalize.setFinalizerExceptionHandler``.

- GHC now provides a set of operations for introspecting on the threads of a
  program, ``GHC.Conc.listThreads``, as well as operations for querying a thread's
  label (:base-ref:`GHC.Conc.threadLabel`) and status
  (:base-ref:`GHC.Conc.threadStatus`).

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

``ghc`` library
~~~~~~~~~~~~~~~

``ghc-heap`` library
~~~~~~~~~~~~~~~~~~~~