4. 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.

4.1. Highlights

The highlights, since the 8.2.1 release, are:

  • Many, many bug fixes.

4.2. Full details

4.2.1. Language

  • 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.

  • 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 -> *)
  • 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
  • GADTs with kind-polymorphic type arguments now require TypeInType. For instance, consider the following,

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

    In previous releases this would compile with PolyKinds alone due to bug Trac #13391. As of GHC 8.4, however, this requires TypeInType. Note that since GADT kind signatures aren’t generalized, this will also require that you provide a CUSK by explicitly quantifying over the kind argument, k,

    data G :: forall k. k -> * where
      GInt   :: G Int
      GMaybe :: G Maybe
  • 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 -XTypeApplications).

4.2.2. Compiler

  • 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.

  • Derived Functor, Foldable, and Traversable instances are now optimized when their last type parameters have phantom roles. Specifically,

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

    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.

    See also Deriving Functor instances, Deriving Foldable instances, and Deriving Traversable instances.

  • Derived Functor, Foldable, Traversable, Generic, and Generic1 instances now have better, and generally better-documented, behaviors for types with no constructors. In particular,

    fmap _ x = case x of
    foldMap _ _ = mempty
    traverse _ x = pure (case x of)
    to x = case x of
    to1 x = case x of
    from x = case x of
    from1 x = case x of

    The new behavior generally leads to more useful error messages than the old did, and lazier semantics for foldMap and traverse.

  • 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.

  • Derived instances for types with no constructors now have appropriate arities: they take all their arguments before producing errors. This may not be terribly important in practice, but it seems like the right thing to do. Previously, we generated

    (==) = error ...

Now we generate

_ == _ = error ...
  • -fsplit-sections is now supported on x86_64 Windows and is on by default. See Trac #12913.
  • Configure on Windows now supports --enable-distro-toolchain which can be used to build a GHC using compilers on your PATH instead of using the bundled bindist. See Trac #13792
  • The optional instance keyword is now usable in type family instance declarations. See Trac #13747
  • Lots of other bugs. See Trac for a complete list.

4.2.3. Runtime system

  • 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().
  • Proper import library support added to GHC which can handle all of the libraries produced by dlltool. The limitation of them needing to be named with the suffix .dll.a is also removed. See Trac #13606, Trac #12499, Trac #12498
  • The GHCi runtime linker on Windows now supports the big-obj file format.
  • The runtime system’s native stack backtrace 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.
  • 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 --install-seh-handlers= Can be used on Wndows to completely disable the runtime’s handling of exceptions. See Trac #13911, Trac #12110.
  • The GHC runtime on Windows can now generate crash dumps on unhandled exceptions using the RTS flag --generate-crash-dumps.
  • 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.
  • 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>.

4.2.4. Template Haskell

  • 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.

    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.

4.2.5. ghc library

  • hsSyn Abstract Syntax Tree (AST) is now extensible via the mechanism described in Trees that Grow

    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
    type ParseI     = RdrName
    type RenameI    = Name
    type TypecheckI = Var

    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)
    type IsPass pass = (DataId pass, OutputableBndrId pass)

    can be used.

4.2.6. base library

  • Blank strings can now be used as values for environment variables using the System.Environment.Blank module. See Trac #12494
  • 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.

4.2.7. 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 Trac #5987).