Skip to content
Snippets Groups Projects
Forked from Glasgow Haskell Compiler / GHC
22953 commits behind the upstream repository.
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
8.0.1-notes.rst 22.25 KiB

.. _release-8-0-1:

Release notes for version 8.0.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 7.10 branch.

Highlights
----------

The highlights, since the 7.10 branch, are:

- TODO FIXME

- nokinds

- Support for :ref:`record pattern synonyms `

- The :ghc-flag:`-XDeriveAnyClass` extension learned to derive instances for
classes with associated types (see :ref:`derive-any-class`)

- More reliable DWARF debugging information

- Support for :ref:`injective type families `

- Applicative ``do`` notation (see :ref:`applicative-do`)

- Support for wildcards in data and type family instances

- :ghc-flag:`-XStrict` and :ghc-flag:`-XStrictData` extensions, allowing modules
to be compiled with strict-by-default bindings (see :ref:`strict-haskell`)

- :ghc-flag:`-XDuplicateRecordFields`, allowing multiple datatypes to declare the same
record field names provided they are used unambiguously (see :ref:`duplicate-record-fields`)

- Support for implicit parameters providing light-weight
:ref:`callstacks and source locations `

- User-defined error messages for type errors

- A rewritten (and greatly improved) pattern exhaustiveness checker

- GHC can run the interpreter in a separate process (see
:ref:`external-interpreter`), and the interpreter can now run profiled
code.

- GHCi now provides access to stack traces when used with
:ghc-flag:`-fexternal-interpreter` and :ghc-flag:`-prof` (see
:ref:`ghci-stack-traces`).

- A native code generator for powerpc64 and powerpc64le architectures

- The reworked users guide you are now reading

- Support for Windows XP and earlier has been dropped.

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

Language
~~~~~~~~

- TODO FIXME.

- The parser now supports Haddock comments on GADT data constructors.
For example ::

data Expr a where
-- | Just a normal sum
Sum :: Int -> Int -> Expr Int

- Implicit parameters of the new ``base`` type :base-ref:`GHC.Stack.CallStack `
are treated specially in function calls, the solver automatically
appends the source location of the call to the ``CallStack`` in
the environment. For example ::

myerror :: (?callStack :: CallStack) => String -> a
myerror msg = error (msg ++ "\n" ++ prettyCallStack ?callStack)

ghci> myerror "die"
*** Exception: die
CallStack (from ImplicitParams):
myerror, called at :2:1 in interactive:Ghci1

prints the call-site of ``myerror``. The name of the implicit
parameter does not matter, but within ``base`` we call it
``?callStack``.

See :ref:`lib-base` for a description of the ``CallStack`` type.

- GHC now supports visible type application, allowing
programmers to easily specify how type parameters should be
instantiated when calling a function. See
:ref:`visible-type-application` for the details.

- To conform to the common case, the default role assigned to
parameters of datatypes declared in ``hs-boot`` files is
``representational``. However, if the constructor(s) for the datatype
are given, it makes sense to do normal role inference. This is now
implemented, effectively making the default role for non-abstract
datatypes in ``hs-boot`` files to be ``phantom``, like it is in
regular Haskell code.

- Wildcards can be used in the type arguments of type/data family
instance declarations to indicate that the name of a type variable
doesn't matter. They will be replaced with new unique type variables.
See :ref:`data-instance-declarations` for more details.

- GHC now allows to declare type families as injective. Injectivity
information can then be used by the typechecker. See
:ref:`injective-ty-fams` for details.

- Due to a :ghc-ticket:`security issue <10826>`, Safe Haskell now forbids
annotations in programs marked as :ghc-flag:`-XSafe`.

- Generic instances can be derived for data types whose constructors have
arguments with certain unlifted types. See :ref:`generic-programming` for
more details.

- GHC generics can now provide strictness information for fields in a data
constructor via the ``Selector`` type class.

- The :ghc-flag:`-XDeriveAnyClass` extension now fills in associated type family
default instances when deriving a class that contains them.

- Users can now define record pattern synonyms. This allows pattern synonyms
to behave more like normal data constructors. For example, ::

pattern P :: a -> b -> (a, b)
pattern P{x,y} = (x,y)

will allow ``P`` to be used like a record data constructor and also defines
selector functions ``x :: (a, b) -> a`` and ``y :: (a, b) -> b``.

- Pattern synonyms can now be bundled with type constructors. For a pattern
synonym ``P`` and a type constructor ``T``, ``P`` can be bundled with ``T``
so that when ``T`` is imported ``P`` is also imported. With this change
a library author can provide either real data constructors or pattern
synonyms in an opaque manner. See :ref:`pattern-synonyms` for details. ::

-- Foo.hs
module Foo ( T(P) ) where

data T = T

pattern P = T

-- Baz.hs
module Baz where

-- P is imported
import Foo (T(..))

- Whenever a data instance is exported, the corresponding data family
is exported, too. This allows one to write ::

-- Foo.hs
module Foo where

data family T a

-- Bar.hs
module Bar where

import Foo

data instance T Int = MkT

-- Baz.hs
module Baz where

import Bar (T(MkT))

In previous versions of GHC, this required a workaround via an
explicit export list in ``Bar``.

Compiler
~~~~~~~~

- Warnings can now be controlled with ``-W(no-)...`` flags in addition to
the old ``-f(no-)warn...`` ones. This was done as the first part of a
rewrite of the warning system to provide better control over warnings,
better warning messages, and more common syntax compared to other
compilers. The old ``-f``-based warning flags will remain functional for
the forseeable future.

- Added the option :ghc-flag:`-dth-dec-file`. This dumps out a .th.hs file of
all Template Haskell declarations in a corresponding .hs file. The
idea is that application developers can check this into their
repository so that they can grep for identifiers used elsewhere that
were defined in Template Haskell. This is similar to using
:ghc-flag:`-ddump-to-file` with :ghc-flag:`-ddump-splices` but it always generates a
file instead of being coupled to :ghc-flag:`-ddump-to-file` and only outputs
code that does not exist in the .hs file and a comment for the splice
location in the original file.

- Added the option :ghc-flag:`-fprint-expanded-types`. When enabled, GHC also
prints type-synonym-expanded types in type errors.

- Added the option :ghc-flag:`-fcpr-anal`. When enabled, the demand analyser
performs CPR analysis. It is implied by :ghc-flag:`-O`. Consequently,
:ghc-flag:`-fcpr-off` is now removed, run with :ghc-flag:`-fno-cpr-anal` to get the
old :ghc-flag:`-fcpr-off` behaviour.

- Added the option :ghc-flag:`-fworker-wrapper`. When enabled, the worker-wrapper
transformation is performed after a strictness analysis pass. It is implied
by :ghc-flag:`-O` and by :ghc-flag:`-fstrictness`. It is disabled by :ghc-flag:`-fno-strictness`.
Enabling :ghc-flag:`-fworker-wrapper` while strictness analysis is disabled (by
:ghc-flag:`-fno-strictness`) has no effect.

- Added the options :ghc-flag:`-Wmissed-specialisations` and
:ghc-flag:`-Wall-missed-specialisations`. When enabled, the simplifier will
produce a warning when a overloaded imported function cannot be
specialised (typically due to a missing ``INLINEABLE`` pragma). This
is intended to alert users to cases where they apply ``INLINEABLE`` but
may not get the speed-up they expect.

- Added the option :ghc-flag:`-Wnoncanonical-monad-instances` which helps
detect noncanonical ``Applicative``/``Monad`` instance definitions.
See flag description in :ref:`options-sanity` for more details.

- When printing an out-of-scope error message, GHC will give helpful advice if
the error might be caused by too restrictive imports.

- Added the :ghc-flag:`-Wcompat` warning group, along with its opposite
:ghc-flag:`-Wno-compat`. Turns on warnings that will be enabled by default in the
future, but remain off in normal compilations for the time being. This
allows library authors eager to make their code future compatible to adapt
to new features before they even generate warnings.

- Added the :ghc-flag:`-Wmissing-monadfail-instance` flag. When enabled, this
will issue a warning if a failable pattern is used in a context that does
not have a ``MonadFail`` constraint. This flag represents phase 1 of the
`MonadFail Proposal (MFP)
`__.

- Added the :ghc-flag:`-Wsemigroup` flag. When enabled, this
will issue a warning if a type is an instance of ``Monoid`` but not
``Semigroup``, and when a custom definition ``(<>)`` is made. Fixing these
warnings makes sure the definition of ``Semigroup`` as a superclass of
``Monoid`` does not break any code.