summaryrefslogtreecommitdiff
path: root/docs/users_guide/9.8.1-notes.rst
blob: 84d9105efd68d8f14cfca305c6598533d9f7728d (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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
.. _release-9-8-1:

Version 9.8.1
=============

Language
~~~~~~~~

- There is a new extension :extension:`ExtendedLiterals`, which enables
  sized primitive literals, e.g. ``123#Int8`` is a literal of type ``Int8#``.
  See the GHC proposal `#451 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0451-sized-literals.rst>`_.

Compiler
~~~~~~~~

- Added a new warning :ghc-flag:`-Wterm-variable-capture` that helps to make code compatible with
  the future extension ``RequiredTypeArguments``.

- Rewrite rules now support a limited form of higher order matching when a
  pattern variable is applied to distinct locally bound variables. For example: ::

      forall f. foo (\x -> f x)

  Now matches: ::

      foo (\x -> x*2 + x)

- GHC Proposal `#496
  <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0496-empty-record-wildcards.rst>`_
  has been implemented, allowing ``{..}`` syntax for constructors without fields, for consistency.
  This is convenient for TH code generation, as you can now uniformly use record wildcards
  regardless of number of fields.

- Incoherent instance applications are no longer specialised. The previous implementation of
  specialisation resulted in nondeterministic instance resolution in certain cases, breaking
  the specification described in the documentation of the `INCOHERENT` pragma. See GHC ticket
  #22448 for further details.

- Fix a bug in TH causing excessive calls to ``setNumCapabilities`` when ``-j`` is greater than ``-N``.
  See GHC ticket #23049.

- The ``-Wno-⟨wflag⟩``, ``-Werror=⟨wflag⟩`` and ``-Wwarn=⟨wflag⟩`` options are
  now defined systematically for all warning groups (for example,
  ``-Wno-default``, ``-Werror=unused-binds`` and ``-Wwarn=all`` are now
  accepted). See :ref:`options-sanity`.

- ``WARNING`` pragmas may now be annotated with a category, following
  `GHC proposal #541 <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0541-warning-pragmas-with-categories.rst>`_, in which case they are controlled with new
  ``-Wx-⟨category⟩`` flags rather than :ghc-flag:`-Wdeprecations`.
  A new warning group :ghc-flag:`-Wextended-warnings` includes all such warnings
  regardless of category.  See :ref:`warning-deprecated-pragma`.

- GHC is now better at disambiguating record updates in the presence of duplicate
  record fields. The following program is now accepted ::

     {-# LANGUAGE DuplicateRecordFields #-}

     data R = MkR1 { foo :: Int }
            | MkR2 { bar :: Int }

     data S = MkS { foo :: Int, bar :: Int }

     blah x = x { foo = 5, bar = 6 }

  The point is that only the type S has a constructor with both fields "foo"
  and "bar", so this record update is unambiguous.

- Data types with ``deriving`` clauses now reject inferred instance contexts
  that mention ``TypeError`` constraints (see :ref:`custom-errors`), such as
  this one: ::

      newtype Foo = Foo Int

      class Bar a where
        bar :: a

      instance (TypeError (Text "Boo")) => Bar Foo where
        bar = undefined

      newtype Baz = Baz Foo
        deriving Bar

  Here, the derived ``Bar`` instance for ``Baz`` would look like this: ::

      instance TypeError (Text "Boo") => Bar Baz

  While GHC would accept this before, GHC 9.8 now rejects it, emitting "``Boo``"
  in the resulting error message. If you really want to derive this instance and
  defer the error to sites where the instance is used, you must do so manually
  with :extension:`StandaloneDeriving`, e.g. ::

      deriving instance TypeError (Text "Boo") => Bar Baz

- GHC Proposal `#540 https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0540-jsem.rst`_ has been implemented.
  This adds the `-jsem`:ghc-flag: flag, which instructs GHC to act as a jobserver client.
  This enables multiple GHC processes running at once to share system resources
  with each other, communicating via the system semaphore specified by
  the flag argument.

- GHC Proposal `#433
  <https://github.com/ghc-proposals/ghc-proposals/blob/master/proposals/0433-unsatisfiable.rst>`_
  has been implemented. This adds the class ``Unsatisfiable :: ErrorMessage -> Constraint``
  to the ``GHC.TypeError`` module. Constraints of the form ``Unsatisfiable msg``
  provide a mechanism for custom type errors that reports the errors in a more
  predictable behaviour than ``TypeError``, as these constraints are
  handled purely during constraint solving.

  For example: ::

      instance Unsatisfiable (Text "There is no Eq instance for functions") => Eq (a -> b) where
        (==) = unsatisfiable

  This allows errors to be reported when users use the instance, even when
  type errors are being deferred.

GHCi
~~~~


Runtime system
~~~~~~~~~~~~~~

- On POSIX systems that support timerfd, RTS shutdown no longer has to wait for
  the next RTS 'tick' to occur before continuing the shutdown process. See #22692.

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

- ``Data.Tuple`` now exports ``getSolo :: Solo a -> a``.

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

- Primitive pointer comparison functions are now levity-polymorphic, e.g. ::

      sameArray# :: forall {l} (a :: TYPE (BoxedRep l)). Array# a -> Array# a -> Int#

  This change affects the following functions:

    - ``sameArray#``, ``sameMutableArray#``,
    - ``sameSmallArray#``, ``sameSmallMutableArray#``,
    - ``sameMutVar#``, ``sameTVar#``, ``sameMVar#``
    - ``sameIOPort#``, ``eqStableName#``.

- New primops for fused multiply-add operations. These primops combine a
  multiplication and an addition, compiling to a single instruction when
  the ``-mfma`` flag is enabled and the architecture supports it.

  The new primops are ``fmaddFloat#, fmsubFloat#, fnmaddFloat#, fnmsubFloat# :: Float# -> Float# -> Float# -> Float#``
  and ``fmaddDouble#, fmsubDouble#, fnmaddDouble#, fnmsubDouble# :: Double# -> Double# -> Double# -> Double#``.

  These implement the following operations, while performing one single
  rounding at the end, leading to a more accurate result:

    - ``fmaddFloat# x y z``, ``fmaddDouble# x y z`` compute ``x * y + z``.
    - ``fmsubFloat# x y z``, ``fmsubDouble# x y z`` compute ``x * y - z``.
    - ``fnmaddFloat# x y z``, ``fnmaddDouble# x y z`` compute ``- x * y + z``.
    - ``fnmsubFloat# x y z``, ``fnmsubDouble# x y z`` compute ``- x * y - z``.

  Warning: on unsupported architectures, the software emulation provided by
  the fallback to the C standard library is not guaranteed to be IEEE-compliant.

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

- The ``RecordUpd`` constructor of ``HsExpr`` now takes an ``HsRecUpdFields``
  instead of ``Either [LHsRecUpdField p] [LHsRecUpdProj p]``.
  Instead of ``Left ..``, use the constructor ``RegularRecUpdFields``, and instead
  of ``Right ..``, use the constructor ``OverloadedRecUpdFields``.

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

``template-haskell`` library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

- Record fields now belong to separate ``NameSpace``s, keyed by the parent of
  the record field. This is the name of the first constructor of the parent type,
  even if this constructor does not have the field in question.
  This change enables TemplateHaskell support for ``DuplicateRecordFields``.

Included libraries
------------------

The package database provided with this distribution also contains a number of
packages other than GHC itself. See the changelogs provided with these packages
for further change information.

.. ghc-package-list::

    libraries/array/array.cabal:             Dependency of ``ghc`` library
    libraries/base/base.cabal:               Core library
    libraries/binary/binary.cabal:           Dependency of ``ghc`` library
    libraries/bytestring/bytestring.cabal:   Dependency of ``ghc`` library
    libraries/Cabal/Cabal/Cabal.cabal:       Dependency of ``ghc-pkg`` utility
    libraries/Cabal/Cabal-syntax/Cabal-syntax.cabal:  Dependency of ``ghc-pkg`` utility
    libraries/containers/containers/containers.cabal: Dependency of ``ghc`` library
    libraries/deepseq/deepseq.cabal:         Dependency of ``ghc`` library
    libraries/directory/directory.cabal:     Dependency of ``ghc`` library
    libraries/exceptions/exceptions.cabal:   Dependency of ``ghc`` and ``haskeline`` library
    libraries/filepath/filepath.cabal:       Dependency of ``ghc`` library
    compiler/ghc.cabal:                      The compiler itself
    libraries/ghci/ghci.cabal:               The REPL interface
    libraries/ghc-boot/ghc-boot.cabal:       Internal compiler library
    libraries/ghc-boot-th/ghc-boot-th.cabal: Internal compiler library
    libraries/ghc-compact/ghc-compact.cabal: Core library
    libraries/ghc-heap/ghc-heap.cabal:       GHC heap-walking library
    libraries/ghc-prim/ghc-prim.cabal:       Core library
    libraries/haskeline/haskeline.cabal:     Dependency of ``ghci`` executable
    libraries/hpc/hpc.cabal:                 Dependency of ``hpc`` executable
    libraries/integer-gmp/integer-gmp.cabal: Core library
    libraries/mtl/mtl.cabal:                 Dependency of ``Cabal`` library
    libraries/parsec/parsec.cabal:           Dependency of ``Cabal`` library
    libraries/pretty/pretty.cabal:           Dependency of ``ghc`` library
    libraries/process/process.cabal:         Dependency of ``ghc`` library
    libraries/stm/stm.cabal:                 Dependency of ``haskeline`` library
    libraries/template-haskell/template-haskell.cabal: Core library
    libraries/terminfo/terminfo.cabal:       Dependency of ``haskeline`` library
    libraries/text/text.cabal:               Dependency of ``Cabal`` library
    libraries/time/time.cabal:               Dependency of ``ghc`` library
    libraries/transformers/transformers.cabal: Dependency of ``ghc`` library
    libraries/unix/unix.cabal:               Dependency of ``ghc`` library
    libraries/Win32/Win32.cabal:             Dependency of ``ghc`` library
    libraries/xhtml/xhtml.cabal:             Dependency of ``haddock`` executable