8.4.1-notes.rst 16.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
.. _release-8-4-1:

Release notes for version 8.4.1
===============================

The significant changes to the various parts of the compiler are listed in the
following sections. There have also been numerous bug fixes and performance
improvements over the 8.2.1 release.


Highlights
----------

The highlights, since the 8.2.1 release, are:

-  Many, many bug fixes.

Full details
------------

Language
~~~~~~~~

24 25 26 27 28 29
- Data families have been generalised a bit: a data family declaration can now
  end with a kind variable ``k`` instead of ``Type``. Additionally, data/newtype
  instance no longer need to list all the patterns of the family if they don't
  wish to; this is quite like how regular datatypes with a kind signature can omit
  some type variables.

30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
- There are now fewer restrictions regarding whether kind variables can appear
  on the right-hand sides of type and data family instances. Before, there was
  a strict requirements that all kind variables on the RHS had to be explicitly
  bound by type patterns on the LHS. Now, kind variables can be *implicitly*
  bound, which allows constructions like these: ::

    data family Nat :: k -> k -> *
    -- k is implicitly bound by an invisible kind pattern
    newtype instance Nat :: (k -> *) -> (k -> *) -> * where
      Nat :: (forall xx. f xx -> g xx) -> Nat f g

    class Funct f where
      type Codomain f :: *
    instance Funct ('KProxy :: KProxy o) where
      -- o is implicitly bound by the kind signature
      -- of the LHS type pattern ('KProxy)
      type Codomain 'KProxy = NatTr (Proxy :: o -> *)

48 49 50 51 52 53 54 55 56 57 58 59 60 61
- Implicitly bidirectional pattern synonyms no longer allow bang patterns
  (``!``) or irrefutable patterns (``~``) on the right-hand side. Previously,
  this was allowed, although the bang patterns and irrefutable patterns would
  be silently ignored when used in an expression context. This is now a proper
  error, and explicitly bidirectional pattern synonyms should be used in their
  stead. That is, instead of using this (which is an error): ::

      data StrictJust a = Just !a

  Use this: ::

      data StrictJust a <- Just !a where
        StrictJust !a = Just a

62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
- GADTs with kind-polymorphic type arguments now require :ghc-flag:`TypeInType`.
  For instance, consider the following, ::

      data G :: k -> * where
        GInt   :: G Int
        GMaybe :: G Maybe

  In previous releases this would compile with :ghc-flag:`PolyKinds` alone due
  to bug :ghc-ticket:`13391`. As of GHC 8.4, however, this requires
  :ghc-flag:`TypeInType`. Note that since GADT kind signatures aren't generalized,
  this will also require that you provide a :ref:`CUSK
  <complete-kind-signatures>` by explicitly quantifying over the kind argument,
  ``k``, ::

      data G :: forall k. k -> * where
        GInt   :: G Int
        GMaybe :: G Maybe

80 81 82 83 84 85 86 87 88 89 90
- The order in which type variables are quantified in GADT constructor type
  signatures has changed. Before, if you had ``MkT`` as below: ::

      data T a where
        MkT :: forall b a. b -> T a

  Then the type of ``MkT`` would (counterintuitively) be
  ``forall a b. b -> T a``! Now, GHC quantifies the type variables in the
  order that the users writes them, so the type of ``MkT`` is now
  ``forall b a. b -> T a`` (this matters for :ghc-flag:`-XTypeApplications`).

91 92 93 94 95 96 97 98 99 100 101 102
- The new :ghc-flag:`-XEmptyDataDeriving` extension allows deriving ``Eq``,
  ``Ord``, ``Read``, and ``Show`` instances directly for empty data types, as
  in ``data Empty deriving Eq``. (Previously, this would require the use of
  :ghc-flag:`-XStandaloneDeriving` to accomplish.)

  One can also now derive ``Data`` instances directly for empty data types (as
  in ``data Empty deriving Data``) without needing to use
  :ghc-flag:`-XStandaloneDeriving`. However, since already requires a GHC
  extension (:ghc-flag:`-XDeriveDataTypeable`), one does not need to enable
  :ghc-flag:`-XEmptyDataDeriving` to do so. This also goes for other classes
  which require extensions to derive, such as :ghc-flag:`-XDeriveFunctor`.

103 104 105 106 107
- Hexadecimal floating point literals (e.g. ``0x0.1p4``), enabled with
  :ghc-flag:`HexFloatLiterals`.  See
  :ref:`Hexadecimal floating point literals <hex-float-literals>`
  for the full details.

108 109 110
Compiler
~~~~~~~~

111 112 113
- Add warning flag :ghc-flag:`-Wmissing-export-lists` which causes the type
  checker to warn when a module does not include an explicit export list.

Ben Gamari's avatar
Ben Gamari committed
114 115 116 117 118 119
- The ``configure`` script now no longer accepts ``--with-TOOL`` flags (e.g.
  ``--with-nm``, ``--with-ld``, etc.). Instead, these are taken from environment
  variables, as is typical in ``autoconf`` scripts. For instance,
  ``./configure --with-nm=/usr/local/bin/nm`` turns into
  ``./configure NM=/usr/local/bin/nm``.

120
- Derived ``Functor``, ``Foldable``, and ``Traversable`` instances are now
David Feuer's avatar
David Feuer committed
121 122
  optimized when their last type parameters have phantom roles.
  Specifically, ::
123 124 125 126 127

    fmap _ = coerce
    traverse _ x = pure (coerce x)
    foldMap _ _ = mempty

David Feuer's avatar
David Feuer committed
128 129 130
  These definitions of ``foldMap`` and ``traverse`` are lazier than the ones we
  would otherwise derive, as they may produce results without inspecting their
  arguments at all.
131

David Feuer's avatar
David Feuer committed
132 133
  See also :ref:`deriving-functor`, :ref:`deriving-foldable`, and
  :ref:`deriving-traversable`.
134

135 136 137 138
- Derived instances for empty data types are now substantially different
  than before. Here is an overview of what has changed. These examples will
  use a running example of ``data Empty a`` to describe what happens when an
  instance is derived for ``Empty``:
139

140 141
  - Derived ``Eq`` and ``Ord`` instances would previously emit code that used
    ``error``: ::
David Feuer's avatar
David Feuer committed
142

143 144
      instance Eq (Empty a) where
        (==) = error "Void =="
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
      instance Ord (Empty a) where
        compare = error "Void compare"

    Now, they emit code that uses maximally defined, lazier semantics: ::

      instance Eq (Empty a) where
        _ == _ = True

      instance Ord (Empty a) where
        compare _ _ = EQ

  - Derived ``Read`` instances would previous emit code that used
    ``parens``: ::

      instance Read (Empty a) where
        readPrec = parens pfail

    But ``parens`` forces parts of the parsed string that it doesn't need to.
    Now, the derived instance will not use ``parens`` (that it, parsing
    ``Empty`` will always fail, without reading *any* input): ::

      instance Read (Empty a) where
        readPrec = pfail

  - Derived ``Show`` instances would previously emit code that used
    ``error``: ::

      instance Show (Empty a) where
        showsPrec = "Void showsPrec"

    Now, they emit code that inspects the argument. That is, if the argument
    diverges, then showing it will also diverge: ::

      instance Show (Empty a) where
        showsPrec _ x = case x of {}

  - Derived ``Functor``, ``Foldable``, ``Traversable``, ``Generic``,
    ``Generic1``, ``Lift``, and ``Data`` instances previously emitted code that
    used ``error``: ::
185

186 187
      instance Functor Empty where
        fmap = error "Void fmap"
188

189 190
      instance Foldable Empty where
        foldMap = error "Void foldMap"
191

192 193
      instance Traversable Empty where
        traverse = error "Void traverse"
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 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
      instance Generic (Empty a) where
        from = M1 (error "No generic representation for empty datatype Empty")
        to (M1 _) = error "No values for empty datatype Empty"
      -- Similarly for Generic1

      instance Lift (Empty a) where
        lift _ = error "Can't lift value of empty datatype Empty"

      instance Data a => Data (Empty a) where
        gfoldl _ _ _ = error "Void gfoldl"
        toConstr _ = error "Void toConstr"
        ...

    Now, derived ``Functor``, ``Traversable, ``Generic``, ``Generic1``,
    ``Lift``, and ``Data`` instances emit code which inspects their
    arguments: ::

      instance Functor Empty where
        fmap _ x = case x of {}

      instance Traversable Empty where
        traverse _ x = pure (case x of {})

      instance Generic (Empty a) where
        from x = M1 (case x of {})
        to (M1 x) = case x of {}

      -- Similarly for Generic1

      instance Lift (Empty a) where
        lift x = pure (case x of {})

      instance Data a => Data (Empty a) where
        gfoldl _ x = case x of {}
        toConstr x = case x of {}
        ...

    Derived ``Foldable`` instances now are maximally lazy: ::

      instance Foldable Empty where
        foldMap _ _ = mempty

- Derived ``Foldable`` instances now derive custom definitions for ``null``
  instead of using the default one. This leads to asymptotically better
  performance for recursive types not shaped like cons-lists, and allows ``null``
  to terminate for more (but not all) infinitely large structures.
241

Ben Gamari's avatar
Ben Gamari committed
242
- :ghc-flag:`-fsplit-sections` is now supported on x86_64 Windows and is on by default.
243 244
  See :ghc-ticket:`12913`.

Ben Gamari's avatar
Ben Gamari committed
245 246 247
- Configure on Windows now supports the ``--enable-distro-toolchain``
  ``configure`` flag, which can be used to build a GHC using compilers on your
  ``PATH`` instead of using the bundled bindist. See :ghc-ticket:`13792`
248

249 250 251 252
- GHC now enables :ghc-flag:`-fllvm-pass-vectors-in-regs` by default. This means
  that GHC will now use native vector registers to pass vector arguments across
  function calls.

253 254 255
- The optional ``instance`` keyword is now usable in type family instance
  declarations. See :ghc-ticket:`13747`

256 257
- Lots of other bugs. See `Trac <https://ghc.haskell.org/trac/ghc/query?status=closed&milestone=8.4.1&col=id&col=summary&col=status&col=type&col=priority&col=milestone&col=component&order=priority>`_
  for a complete list.
258 259 260 261

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

262 263
- Function ``hs_add_root()`` was removed. It was a no-op since GHC-7.2.1
  where module initialisation stopped requiring a call to ``hs_add_root()``.
264

265
- Proper import library support added to GHC which can handle all of the libraries produced
266 267 268
  by ``dlltool``. The limitation of them needing to be named with the suffix
  ``.dll.a`` is also removed. See :ghc-ticket:`13606`, :ghc-ticket:`12499`,
  :ghc-ticket:`12498`
269

270
- The GHCi runtime linker on Windows now supports the ``big-obj`` file format.
271

272 273 274 275 276 277
- The runtime system's :ref:`native stack backtrace <backtrace-signal>` support
  on POSIX platforms is now triggered by ``SIGQUIT`` instead of ``SIGUSR2`` as
  it was in previous releases. This change is to bring GHC's behavior into
  compliance with the model set by the most Java virtual machine
  implementations.

278 279 280 281 282 283 284
- The GHC runtime on Windows now uses Continue handlers instead of Vectorized
  handlers to trap exceptions. This change gives other exception handlers a chance
  to handle the exception before the runtime does. Furthermore The RTS flag
  :rts-flag:`--install-seh-handlers=<yes|no>` Can be used on Wndows to
  completely disable the runtime's handling of exceptions. See
  :ghc-ticket:`13911`, :ghc-ticket:`12110`.

285 286 287
- The GHC runtime on Windows can now generate crash dumps on unhandled exceptions
  using the RTS flag :rts-flag:`--generate-crash-dumps`.

288 289 290 291
- The GHCi runtime linker now avoid calling GCC to find libraries as much as possible by caching
  the list of search directories of GCC and querying the file system directly. This results in
  much better performance, especially on Windows.

292 293 294 295
- The GHC runtime on Windows can now generate stack traces on unhandled exceptions.
  When running in GHCi more information is displayed about the symbols if available.
  This behavior can be controlled with the RTS flag `--generate-stack-traces=<yes|no>`.

296 297 298
Template Haskell
~~~~~~~~~~~~~~~~

299 300 301 302 303 304
- Template Haskell now reifies data types with GADT syntax accurately.
  Previously, TH used heuristics to determine whether a data type
  should be reified using GADT syntax, which could lead to incorrect results,
  such as ``data T1 a = (a ~ Int) => MkT1`` being reified as a GADT and
  ``data T2 a where MkT2 :: Show a => T2 a`` *not* being reified as a GADT.

305 306 307 308 309 310 311 312 313 314
  In addition, reified GADT constructors now more accurately track the order in
  which users write type variables. Before, if you reified ``MkT`` as below: ::

      data T a where
        MkT :: forall b a. b -> T a

  Then the reified type signature of ``MkT`` would have been headed by
  ``ForallC [PlainTV a, PlainTV b]``. Now, reifying ``MkT`` will give a type
  headed by ``ForallC [PlainTV b, PlainTV a]``, as one would expect.

315 316
``ghc`` library
~~~~~~~~~~~~~~~
317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350

- hsSyn Abstract Syntax Tree (AST) is now extensible via the mechanism described in `Trees that Grow <http://www.jucs.org/jucs_23_1/trees_that_grow/jucs_23_01_0042_0062_najd.pdf>`_

  The main change for users of the GHC API is that the AST is no longer indexed
  by the type used as the identifier, but by a specific index type, ::

      type GhcPs   = GhcPass 'Parsed      -- Old 'RdrName' type param
      type GhcRn   = GhcPass 'Renamed     -- Old 'Name' type param
      type GhcTc   = GhcPass 'Typechecked -- Old 'Id' type para,
      type GhcTcId = GhcTc                -- Old 'TcId' type param

  The simplest way to support the current GHC as well as earlier ones is to define ::

      #if MIN_VERSION_ghc(8,3,0)
      type ParseI     = GhcPs
      type RenameI    = GhcRn
      type TypecheckI = GhcTc
      #else
      type ParseI     = RdrName
      type RenameI    = Name
      type TypecheckI = Var
      #endif

  and then replace all hardcoded index types accordingly. For polymorphic types,
  the constraint ::

      #if MIN_VERSION_ghc(8,3,0)
      -- |bundle up the constraints required for a trees that grow pass
      type IsPass pass = (DataId pass, OutputableBndrId pass, SourceTextX pass)
      else
      type IsPass pass = (DataId pass, OutputableBndrId pass)
      #endif

  can be used.
351 352 353 354 355

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

- Blank strings can now be used as values for environment variables using the
356
  ``System.Environment.Blank`` module. See :ghc-ticket:`12494`
357

David Feuer's avatar
David Feuer committed
358 359 360 361 362 363 364 365
- ``Data.Type.Equality.==`` is now a closed type family. It works for all kinds
  out of the box. Any modules that previously declared instances of this family
  will need to remove them. Whereas the previous definition was somewhat ad
  hoc, the behavior is now completely uniform. As a result, some applications
  that used to reduce no longer do, and conversely. Most notably, ``(==)`` no
  longer treats the ``*``, ``j -> k``, or ``()`` kinds specially; equality is
  tested structurally in all cases.

366 367 368 369 370 371 372 373 374
Build system
~~~~~~~~~~~~

- ``dll-split`` has been removed and replaced with an automatic partitioning utility ``gen-dll``.
  This utility can transparently split and compile any DLLs that require this. Note that the ``rts`` and
  ``base`` can not be split at this point because of the mutual recursion between ``base`` and ``rts``.
  There is currently no explicit dependency between the two in the build system and such there is no way
  to notify ``base`` that the ``rts`` has been split, or vice versa.
  (see :ghc-ticket:`5987`).
375

376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413

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:   Deppendency of ``ghc`` library
    libraries/Cabal/Cabal/Cabal.cabal:       Dependency of ``ghc-pkg`` utility
    libraries/containers/containers.cabal:   Dependency of ``ghc`` library
    libraries/deepseq/deepseq.cabal:         Dependency of ``ghc`` library
    libraries/directory/directory.cabal:     Dependency of ``ghc`` 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-compact/ghc-compact.cabal: Core 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/process/process.cabal:         Dependency of ``ghc`` library
    libraries/template-haskell/template-haskell.cabal:     Core 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

414 415 416
Win32
~~~~~

417 418 419 420
.. attention::

    This release is a backwards incompatible release which corrects the type of
    certain APIs. See issue `#24 <https://github.com/haskell/win32/issues/24>`_.