3. 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.
Warning
Only Cabal versions 1.24 and newer will function properly with this release.
(see Trac #11558). Consequently it will likely be necessary to
recompile cabal-install before installing new packages.
The reason for this is a change in how packages are identified in GHC
8.0. While previous versions of Cabal identified packages to GHC with a
package key (with GHC’s -this-package-key argument), GHC 8.0 and
later uses installed package IDs in place of package keys.
Note
Users compiling GHC on Mac OS X with XCode 7.3 will need to tell the build
system to use the nm-classic command instead of Apple’s new nm
implementation as the latter breaks POSIX compliance (see
Trac #11744). This can be done by passing something like
--with-nm=$(xcrun --find nm-classic) to configure.
3.1. Highlights¶
The highlights, since the 7.10 series, are:
- The new
-XTypeInTypeallows promotion of all types into kinds, allowing kind synonyms, kind families, promoted GADTs, and other goodies. - Support for record pattern synonyms
- The
-XDeriveAnyClassextension learned to derive instances for classes with associated types (see Deriving any other class) - More reliable DWARF debugging information
- Support for injective type families
- Applicative
donotation (see Applicative do-notation) - Support for wildcards in data and type family instances
-XStrictand-XStrictDataextensions, allowing modules to be compiled with strict-by-default bindings (see Bang patterns and Strict Haskell)-XDuplicateRecordFields, allowing multiple datatypes to declare the same record field names provided they are used unambiguously (see Duplicate record fields)- Support for lightweight 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 Running the interpreter in a separate process), and the interpreter can now run profiled code.
- GHCi now provides access to stack traces when used with
-fexternal-interpreterand-prof(see Stack Traces in GHCi). - A native code generator for powerpc64 and powerpc64le architectures, support for AIX targets, and significantly improved support on ARM.
- The reworked users guide you are now reading
- Support for Windows XP and earlier has been dropped.
- GHC RTS No longer re-exports POSIX functions under their deprecated names on Windows.
3.2. Full details¶
3.2.1. Language¶
-XTypeInTypesupports universal type promotion and merges the type and kind language. This allows, for example, higher-rank kinds, along with kind families and type-level GADTs. Support is still experimental, and it is expected to improve over the next several releases. See Kind polymorphism and Type-in-Type for the details.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
The new
baseconstraint GHC.Stack.HasCallStack can be used by functions to request a partial call-stack. For exampleerrorWithCallStack :: HasCallStack => String -> a errorWithCallStack msg = error (msg ++ "\n" ++ prettyCallStack callStack) ghci> errorWithCallStack "die" *** Exception: die CallStack (from HasCallStack): errorWithCallStack, called at <interactive>:2:1 in interactive:Ghci1
prints the call-site of
errorWithCallStack.See HasCallStack for a description of
HasCallStack.GHC now supports visible type application, allowing programmers to easily specify how type parameters should be instantiated when calling a function. See Visible type application for the details.
To conform to the common case, the default role assigned to parameters of datatypes declared in
hs-bootfiles isrepresentational. 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 inhs-bootfiles to bephantom, 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 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 Injective type families for details.
Due to a security issue, Safe Haskell now forbids annotations in programs marked as
-XSafe.Generic instances can be derived for data types whose constructors have arguments with certain unlifted types. See Generic programming for more details.
GHC generics can now provide strictness information for fields in a data constructor via the
Selectortype class.The
-XDeriveAnyClassextension 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
Pto be used like a record data constructor and also defines selector functionsx :: (a, b) -> aandy :: (a, b) -> b.Pattern synonyms can now be bundled with type constructors. For a pattern synonym
Pand a type constructorT,Pcan be bundled withTso that whenTis importedPis also imported. With this change a library author can provide either real data constructors or pattern synonyms in an opaque manner. See Import and export of 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.GHC has grown a
-XUndecidableSuperClasseslanguage extension, which relaxes GHC’s recursive superclass check (see Trac #10318). This allows class definitions which have mutually recursive superclass constraints at the expense of potential non-termination in the solver.The compiler is now a bit more conservative in solving constraints previously provided by superclasses (see Trac #11762). For instance, consider this program,:
{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} class Super a class (Super a) => Left a class (Super a) => Right a instance (Left a) => Right a -- this is now an error
GHC now rejects this instance, claiming it cannot deduce the
Super asuperclass constraint of theRighttypeclass. This stands in contrast to previous releases, which would accept this declaration, using theSuper aconstraint implied by theLeft aconstraint. To fix this simply add the needed superclass constraint explicitly,instance (Left a, Super a) => Right a
-XDeriveFoldableand-XDeriveTraversablenow generate code without superfluousmemptyorpureexpressions. As a result,-XDeriveTraversablenow works on datatypes that contain arguments which have unlifted types.Note that the
-XImpredicativeTypesextension, which has been known to be broken for many years, is even more broken than usual in this release (see Trac #11319, Trac #11675, and others). During pre-release testing we encountered a number of projects that broke with confusing type errors due to (often unnecessary) use of-XImpredicativeTypes. Users of-XImpredicativeTypesdo so at their own risk!
3.2.2. Compiler¶
The LLVM code generator now supports only LLVM 3.7. This is in contrast to our previous policy where GHC would try to support a range of LLVM versions concurrently. We hope that by supporting a narrower range of versions we can provide more reliable support for each.
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
-dth-dec-file. This dumps out a.th.hsfile 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-ddump-to-filewith-ddump-splicesbut it always generates a file instead of being coupled to-ddump-to-fileand 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
-fprint-expanded-types. When enabled, GHC also prints type-synonym-expanded types in type errors.Added the option
-fcpr-anal. When enabled, the demand analyser performs CPR analysis. It is implied by-O. Consequently,-fcpr-offis now removed, run with-fno-cpr-analto get the old-fcpr-offbehaviour.Added the option
-fworker-wrapper. When enabled, the worker-wrapper transformation is performed after a strictness analysis pass. It is implied by-Oand by-fstrictness. It is disabled by-fno-strictness. Enabling-fworker-wrapperwhile strictness analysis is disabled (by-fno-strictness) has no effect.-ddump-strsigshas been renamed to-ddump-str-signatures.-XDeriveGenericis now less picky about instantiating type arguments when deriving (Trac #11732). As a consequence, the following code is now legal (whereas before it would have been rejected).data T a b = T a b deriving instance Generic (T Int b)
Added the
-fmax-pmcheck-iterationsto control how many times the pattern match checker iterates. Since coverage checking is exponential in the general case, setting a default number of iterations prevents memory and performance blowups. By default, the number of iterations is set to 2000000 but it can be set with:-fmax-pmcheck-iterations=<n>. If the set number of iterations is exceeded, an informative warning is issued.-this-package-keyhas been renamed again (hopefully for the last time!) to-this-unit-id. The renaming was motivated by the fact that the identifier you pass to GHC here doesn’t have much to do with packages: you may provide different unit IDs for libraries which are in the same package.-this-package-keyis deprecated; you should use-this-unit-idor, if you need compatibility over multiple versions of GHC,-package-name.When
-fdefer-type-errorsis enabled and an expression fails to typecheck,Control.Exception.TypeErrorwill now be thrown instead ofControl.Exception.ErrorCall.
3.2.2.1. Warnings¶
- When printing an out-of-scope error message, GHC will give helpful advice if the error might be caused by too restrictive imports.
- Warning messages now mention the name of the warning flag which the message is
controlled by (Trac #10752) If the flag was implied via a warning
group then the name of the group will also be shown if
-fshow-warning-groupsis used. - Added the
-Weverythingwarning group, along with its opposite-Wno-everything. This group includes all warnings supported by GHC. This is in contrast to -Wall which excludes some stylistic or otherwise controversial warnings. - Added the
-Wdefaultwarning group, along with its opposite-Wno-default. This group is defined to be the set of warnings whichghcenables by default (e.g. when no additional-Wflags are used). - Added the
-Wcompatwarning group (Trac #11000), along with its opposite-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
-Wmissing-monadfail-instancesflag. When enabled, this will issue a warning if a failable pattern is used in a context that does not have aMonadFailconstraint. This flag represents phase 1 of the MonadFail Proposal (MFP). - Added the
-Wsemigroupflag. When enabled, this will issue a warning if a type is an instance ofMonoidbut notSemigroup, and when a custom definition(<>)is made. Fixing these warnings makes sure the definition ofSemigroupas a superclass ofMonoiddoes not break any code. - After a long hiatus (see Trac #10935) the
-Wmonomorphism-restriction(formerly-fwarn-monomorphism-restriction) flag has returned. The functionality of this flag was inadvertently removed by a commit in 2010; this has been fixed and the flag should now issue warnings as it previously did. - Added the options
-Wmissed-specialisationsand-Wall-missed-specialisations. When enabled, the simplifier will produce a warning when a overloaded imported function cannot be specialised (typically due to a missingINLINEABLEpragma). This is intended to alert users to cases where they applyINLINEABLEbut may not get the speed-up they expect. - Added the option
-Wnoncanonical-monad-instancesand-Wnoncanonical-monadfail-instanceswhich help detect noncanonicalApplicative/Monad/MonadFailinstance definitions. See flag description in Warnings and sanity-checking for more details. - Added the option
-Wnoncanonical-semigroup-instanceswhich warns ofMonoidinstances wheremappendis not defined in term ofSemigroup‘s(<>)operation. - Added the
-Wmissing-pattern-synonym-signaturesflag. When enabled, this will issue a warning when a pattern synonym definition doesn’t have a type signature. It is turned off by default but enabled by-Wall. - Added the
-Wunused-type-patternsflag to report unused type variables in data and type family instances. This flag is not implied by-Wall, since-Wunused-type-patternswill warn about unused type variables even if the types themselves are intended to be used as documentation. If-Wunused-type-patternsis enabled, one can prefix or replace unused type variables with underscores to avoid warnings. - Split off the new flag
-Wunused-forallsfrom the previously existing flag-Wunused-matches.-Wunused-forallsemits a warning in the specific case that a user writes explicitforallsyntax with unused type variables, while-Wunused-matchesonly warns in the case of unused term-level patterns. Both flags are implied by-W. -Wmissing-local-sigsis now deprecated in favor of-Wmissing-local-signatures.-Wmissing-exported-sigsis now deprecated in favor of-Wmissing-exported-signatures.
3.2.3. GHCi¶
Mainwith an explicit module header but withoutmainis now an error (Trac #7765).- The
:backand:forwardcommands now take an optional count allowing the user to move forward or backward in history several steps at a time. - Added commands
:load!and:reload!, effectively setting-fdefer-type-errorsbefore loading a module and unsetting it after loading if it has not been set before (Trac #8353). ghci -enow behaves likeghc -e(Trac #9360).- Added support for top-level function declarations (Trac #7253).
- The new commands
:all-types,:loc-at,:type-at, and:usesdesigned for editor-integration (such as Emacs’haskell-mode) originally premiered byghci-nghave been integrated into GHCi (Trac #10874).
3.2.4. Template Haskell¶
- The new
-XTemplateHaskellQuotesflag allows to use the quotes (not quasi-quotes) subset ofTemplateHaskell. This is particularly useful for use with a stage 1 compiler (i.e. GHC without interpreter support). Also,-XTemplateHaskellQuotesis considered safe under Safe Haskell. - The
__GLASGOW_HASKELL_TH__CPP constant denoting support for-XTemplateHaskellintroduced in GHC 7.10.1 has been changed to use the values1/0instead of the previousYES/NOvalues. - Partial type signatures can now be used in splices, see Where can they occur?.
- Template Haskell now fully supports typed holes and quoting unbound variables. This means it is now possible to use pattern splices nested inside quotation brackets.
- Template Haskell now supports the use of
UInfixTin types to resolve infix operator fixities, in the same vein asUInfixPandUInfixEin patterns and expressions.ParensTandInfixThave also been introduced, serving the same functions as their pattern and expression counterparts. - Template Haskell has now explicit support for representing GADTs. Until
now GADTs were encoded using
NormalC,RecC(record syntax) andForallCconstructors. Two new constructors -GadtCandRecGadtC- are now supported during quoting, splicing and reification. - Primitive chars (e.g.,
[| 'a'# |]) and primitive strings (e.g.,[| "abc"# |]) can now be quoted with Template Haskell. TheLitdata type also has a new constructor,CharPrimL, for primitive char literals. addTopDeclsnow accepts annotation pragmas.- Internally, the implementation of quasi-quotes has been unified with
that of normal Template Haskell splices. Under the previous
implementation, top-level declaration quasi-quotes did not cause a
break in the declaration groups, unlike splices of the form
$(...). This behavior has been preserved under the new implementation, and is now recognized and documented in Syntax. - The
Liftclass is now derivable via the-XDeriveLiftextension. See Deriving Lift instances for more information. - The
FamilyDdata constructor andFamFlavourdata type have been removed. Data families are now represented byDataFamilyDand open type families are now represented byOpenTypeFamilyDinstead ofFamilyD. Common elements ofOpenTypeFamilyDandClosedTypeFamilyDhave been moved toTypeFamilyHead. - The representation of
data,newtype,data instance, andnewtype instancedeclarations has been changed to allow for multi-parameter type classes in thederivingclause. In particular,dataDandnewtypeDnow take aCxtQinstead of a[Name]for the list of derived classes. isExtEnabledcan now be used to determine whether a language extension is enabled in theQmonad. Similarly,extsEnabledcan be used to list all enabled language extensions.- One can now reify the strictness information of a constructors’ fields using
Template Haskell’s
reifyConStrictnessfunction, which takes into account whether flags such as-XStrictDataor-funbox-strict-fieldsare enabled. - Previously, quoting a type signature like
a -> awould produce the abstract syntax forforall a. a -> a. This behavior remains, but it is extended to kinds, too, meaning thatProxy a -> Proxy abecomesforall k (a :: k). Proxy a -> Proxy a. This change is not intentional, but is forced by the fact that GHC has a hard time telling kinds apart from types. The effect of this change is that round-tripping kind- polymorphic types will now require-XTypeInType.
3.2.5. Runtime system¶
- We have a shiny new two-step memory allocator for 64-bit platforms (see Trac #9706). In addition to simplifying the runtime system’s implementation this may significantly improve garbage collector performance. Note, however, that Haskell processes will have an apparent virtual memory footprint of a terabyte or so. Don’t worry though, most of this amount is merely mapped but uncommitted address space which is not backed by physical memory.
- Support for performance monitoring with PAPI has been dropped.
-maxN⟨x⟩flag added to complement-N. It will choose to use at most ⟨x⟩ capabilities, limited by the number of processors as-Nis.- The runtime linker is no longer greedy and will load only the needed objects from archives. This means particularly on Windows packages requiring e.g. C99 support will now function properly. As part of this the RTS on Windows no longer re-exports deprecated POSIX functions under the undeprecated names (see Trac #11223).
- A number of subtle but serious issues in the runtime linker were resolved on ARM (summarized in Trac #11206).
3.2.6. Build system¶
- Nothing changed here.
3.2.7. Package system¶
- Various internal changes but nothing user-facing.
3.2.8. hsc2hs¶
hsc2hs now supports the
#alignmentmacro, which can be used to calculate the alignment of a struct in bytes. Previously,#alignmenthad to be implemented manually via a#letdirective, e.g.,#let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__)
As a result, if you have the above directive in your code, it will now emit a warning when compiled with GHC 8.0.
Module.hsc:24:0: warning: "hsc_alignment" redefined [enabled by default] In file included from dist/build/Module_hsc_make.c:1:0: /path/to/ghc/lib/template-hsc.h:88:0: note: this is the location of the previous definition #define hsc_alignment(t...) \ ^
To make your code free of warnings on GHC 8.0 and still support earlier versions, surround the directive with a pragma checking for the right GHC version.
#if __GLASGOW_HASKELL__ < 800 #let alignment t = "%lu", (unsigned long)offsetof(struct {char x__; t (y__); }, y__) #endif
3.3. Libraries¶
3.3.1. array¶
- Version number 0.5.1.1 (was 0.5.1.0)
3.3.2. base¶
See changelog.md in the base package for full release notes.
Version number 4.9.0.0 (was 4.8.2.0)
GHC.Stack exports two new types
SrcLocandCallStack. ASrcLoccontains package, module, and file names, as well as start and end positions. ACallStackis essentially a[(String, SrcLoc)], sorted by most-recent call.errorandundefinedwill now report a partial stack-trace using the newCallStackfeature (and the-profstack if available).A new function,
interruptible, was added toGHC.IOallowing anIOaction to be run such that it can be interrupted by an asynchronous exception, even if exceptions are masked (except if masked withinterruptibleMask).This was introduced to fix the behavior of
allowInterrupt, which would previously incorrectly allow exceptions in uninterruptible regions (see Trac #9516).Per-thread allocation counters (
setAllocationCounterandgetAllocationCounter) and limits (enableAllocationLimit,disableAllocationLimitare now available fromSystem.Mem. Previously this functionality was only available from GHC.Conc.forever,filterM,mapAndUnzipM,zipWithM,zipWithM_,replicateM, andreplicateMwere generalized fromMonadtoApplicative. If this causes performance regressions, try to make the implementation of(*>)match that of(>>)(see Trac #10168).Add
URec,UAddr,UChar,UDouble,UFloat,UInt, andUWordto GHC.Generics as part of making GHC generics capable of handling unlifted types (Trac #10868)Expand
Floatingclass to include operations that allow for better precision:log1p,expm1,log1pexpandlog1mexp. These are not available fromPrelude, but the full class is exported fromNumeric.Add
Data.List.NonEmptyandData.Semigroup(to become super-class ofMonoidin the future). These modules were provided by thesemigroupspackage previously. (Trac #10365)Add
GHC.TypeLits.TypeErrorandErrorMessageto allow users to define custom compile-time error messages. (see Custom compile-time errors and the original proposal).The datatypes in
GHC.Genericsnow haveEnum,Bounded,Ix,Functor,Applicative,Monad,MonadFix,MonadPlus,MonadZip,Foldable,Foldable,Traversable,Generic1, andDatainstances as appropriate. (Trac #9043)The
Genericinstance forProxyis now poly-kinded (see Trac #10775)The
IsStringinstance for[Char]has been modified to eliminate ambiguity arising from overloaded strings and functions like(++).Move
ConstfromControl.Applicativeto its own module inData.Functor.Const. (see Trac #11135)Enable
PolyKindsin theData.Functor.Constmodule to giveConstthe kind* -> k -> *(see Trac #10039).Add the
TypeErrordatatype toControl.Exception, which represents the error that is thrown when an expression fails to typecheck when run using-fdefer-type-errors. (see Trac #10284)
3.3.3. binary¶
- Version number 0.8.3.0 (was 0.7.5.0)
3.3.4. bytestring¶
- Version number 0.10.8.0 (was 0.10.6.0)
3.3.5. Cabal¶
- Version number 1.24.0 (was 1.22.5.0)
3.3.6. containers¶
- Version number 0.5.7.1 (was 0.5.6.2)
3.3.7. deepseq¶
- Version number 1.4.2.0 (was 1.4.1.1)
3.3.8. directory¶
- Version number 1.2.6.2 (was 1.2.2.0)
3.3.9. filepath¶
- Version number 1.4.1.0 (was 1.4.0.0)
3.3.10. ghc¶
- The
HsBangtype has been removed in favour ofHsSrcBangandHsImplBang. Data constructors now always carry around their strictness annotations as the user wrote them, whether from an imported module or not. - Moved
startsVarSym,startsVarId,startsConSym,startsConId,startsVarSymASCII, andisVarSymCharfromLexemeto theGHC.Lemexemodule of theghc-bootlibrary. - Add
isImport,isDecl, andisStmtfunctions. - The mi_fix_fn field of ModIface had its type changed from
OccName -> FixitytoOccName -> Maybe Fixity, where a returned value ofNothingindicates a cache miss. As a result, the types ofmkIfaceFixCacheandemptyIfaceFixCachewere also changed to have a return type ofMaybe Fixity, and a newmi_fix :: OccName -> Fixityfunction was introduced which invokesmi_fix_fnbut returnsdefaultFixityupon a cache miss.
3.3.11. ghc-boot¶
- This is an internal package. Use with caution.
- Version number 8.0.1
- This package was renamed from
bin-package-dbto reflect its new purpose of containing intra-GHC functionality that needs to be shared across multiple GHC boot libraries.
3.3.12. ghc-boot-th¶
- This is an internal package. Use with caution.
- Version number 8.0.1
- This package was created to share types and utilities between the
ghcandtemplate-haskellpackages - Added
GHC.Lexeme, which contains functions for determining if a character can be the first letter of a variable or data constructor in Haskell, as defined by GHC. (These functions were moved fromLexemeinghc.) - Added
GHC.LanguageExtensionswhich contains a type listing all supported language extensions.
3.3.13. ghc-prim¶
- Version number 0.5.0.0 (was 0.4.0.0)
3.3.14. haskell98¶
- No longer shipped
3.3.15. haskell2010¶
- No longer shipped. We hope that this package or something like it will be restored in a future GHC release.
3.3.16. hoopl¶
- Version number 3.10.2.1 (was 3.10.0.2)
3.3.17. hpc¶
- Version number 0.6.0.3 (was 0.6.0.2)
3.3.18. integer-gmp¶
- Version number 1.0.0.1 (was 0.5.1.0)
3.4. old-locale¶
- No longer shipped
3.4.1. old-time¶
- No longer shipped
3.4.2. process¶
- Version number 1.4.2.0 (was 1.2.3.0)
3.4.3. template-haskell¶
- Version number 2.11.0.0 (was 2.10.0.0)
- The
Lifttype class for lifting values into Template Haskell splices now has a default signaturelift :: Data a => a -> Q Exp, which means that you do not have to provide an explicit implementation ofliftfor types which have aDatainstance. To manually use this default implementation, you can use theliftDatafunction which is now exported fromLanguage.Haskell.TH.Syntax. Info‘s constructors no longer haveFixityfields. AqReifyFixityfunction was added to theQuasitype class (as well as thereifyFixityfunction, specialized forQ) to allow lookup of fixity information for any givenName.
3.4.4. time¶
- Version number 1.6.0.1 (was 1.5.0.1)
3.4.5. unix¶
- Version number 2.7.2.0 (was 2.7.1.0)
3.4.6. Win32¶
- Version number 2.3.1.1 (was 2.3.1.0)
3.5. Known bugs¶
- The Haddock release shipped with the release currently does not show bundled pattern synonyms in generated documentation (Trac #11954).