1.4. Release notes for version 6.4

1.4.1. User-visible compiler changes

  • GADTs (Generalised Abstract Datatypes) are now supported. See Section 7.5, “Generalised Algebraic Data Types”.

  • Support for Software Transactional Memory, a new method for communication between concurrent threads. Documentation is a bit light so far, but see Control.Concurrent.STM. Also, there is a paper on STM.

  • There is a new machanism for mutually recursive modules: see Section 4.6.9, “How to compile mutually recursive modules”. Modules which are to be imported before they are compiled must have a .hs-boot file rather than a .hi-boot file. The .hs-boot file is compiled into a .hi-boot file by the compiler, this removes the previous restriction that only original names can be used in the .hi-boot file.

    The declarations in the .hs-boot file are also checked for consistency when the real module is compiled.

    Dependencies from .hs-boot files are now tracked properly. The dependency generator, ghc -M, now follows imports recursively, just like ghc --make. So you can usually say simply ghc -M Main rather than listing the source files explicitly (ghc -M *.hs).

  • GHC now includes the Cabal framework, which entails lots of changes to the package system: see Section 4.8, “ Packages ” for details. Packages now have versions, and it is possible to have multiple versions of a package installed (but only one version can be used in a given program). Packages can now contain “hidden” modules, that is modules which are not allowed to be imported by the client.

    There are some new GHC options: -hide-package and -ignore-package, and the -package-name option is now deprecated. The ghc-pkg command has a new command-line syntax, and the format of the package files it accepts is also new.

  • GHC now keeps much more accurate source locations in its internal abstract syntax. By default, this results in error messages which contain column numbers in addition to line numbers. e.g.

         read001.hs:25:10: Variable not in scope: `+#'

    Additionally, you can ask GHC to report the full span (start and end-location) for error messages by giving the -ferror-spans option (See Section 4.5, “Help and verbosity options”). e.g.

         read001.hs:25:10-11: Variable not in scope: `+#'

  • Template Haskell changes:

    • The main TH syntax data type now uses Name instead of String for names (both binding sites and occurrences).

    • There is new quoting syntax to refer to the Name of an in-scope identifier: 'x for variables and data constructors, and ''T for type constructors and classes.

    • The reify function now takes a Name and returns an Info structure, which describes the thing that has been reified.

    All these changes are described in a short note; and Language.Haskell.TH.Syntax gives the definitions of all the relevant types and functions.

  • The OPTIONS pragma has been renamed to OPTIONS_GHC (OPTIONS is still accepted, but deprecated). See Section 7.9.5, “OPTIONS_GHC pragma”.

  • Deprecation annotations now travel with an entity if it is re-exported.

  • When not optimising, GHC will now not emit the definitions of data constructors into the interface file. This will result in less recompilation when datatypes change and optimisation is off.

  • Changes to scoped type variables: type signatures may now bind type variables which scope over the definition of the function. This happens if the type variables are bound by an explicit forall in the type signature (see Section 7.4.10, “Scoped type variables ”).

  • Under -fallow-overlapping-instances overlapping-instance errors are checked and reported lazily, rather than eagerly (see Section 7.4.4.1, “Overlapping instances”). Previously a program was rejected if two instance declarations could lead to a situation in which a constraint matches both instances without one being more specific than the other. Now the program is rejected only if a constraint is actually encountered which leads to this ambiguous situation. This is basically good, but it means you need the -fallow-overlapping-instances flag in the module that calls the overloaded function, rather than the one that defines it.

  • Outstanding finalizers are no longer run at the end of program execution. Before, GHC was attempting to guarantee that finalizers were always run, but in fact it failed to provide this guarnatee in some cases. Providing this guarantee in general is hard, maybe impossible.

    Finalizers are used to close and flush Handles. To prevent undue surprise, stdout and stderr are now always flushed at the end of program execution. Other Handles are not flushed on exit, however: we recommend that all Handles be explicitly closed when they are no longer required.

  • The runghc program is included, which loads and runs a Haskell script given as an argument. It is equivalent to ghc -e Main.main, but can be used to run Haskell scripts on systems that understand the #! syntax for script files (eg. #! /usr/bin/runhaskell).

    Depending on your installation of GHC, and what other Haskell compilers you have installed, runhaskell may be a synonym for runghc.

  • Windows: in a GUI-only program (compiled with -optl-mwindows) trace messages from Debug.Trace are sent to the debug console. A standard Windows debugger can be used to view the messages. Also, error messages from the RTS are sent to popped up in a message box, and debugging messages from the RTS are sent to the debug console.

    In a GUI-only Windows program, the stdout and stderr Handles should not be used. They will usually not be connected to valid file descriptors, and attempting to output via these handles will probably result in an exception.

  • New flag: -fwarn-orphans. See Section 4.7, “Warnings and sanity-checking”.

  • GHC now defines os_HOST_OS and arch_HOST_ARCH, where os and arch are the current operating system and architecture respectively, when compiling with -cpp. This avoids the need to include ghcconfig.h in many cases.

  • -fgenerics is now required to get derivable type-class support (previously this was the default). The libraries are all built with this flag on.

  • -optdep-include-prelude is now called -optdep-include-pkg-deps. Section 4.6.11, “Dependency generation”.

  • The -c flag can now be used at the same time as --make, which makes the -no-link flag superfluous. Hence, -no-link is now deprecated.

1.4.2. User-visible interpreter (GHCi) changes

  • The :type and :info commands no longer emit types with explicit foralls, unless the -fglasgow-exts option is on.

  • The :info command now shows instances of classes and datatypes, but only those that refer to classes or types that are in scope.

  • Windows: Ctrl-C works to some extent in GHCi. Best results when using GHCi in a standard Windows Command Shell, rather than a cygwin shell window.

1.4.3. User-visible library changes

1.4.4. Experimental features

  • Initial support for position-independent code and dynamic linking is in. Allegedly works on PowerPC/MacOS X, not quite ready on x86/Linux and other platforms yet.

1.4.5. Internal changes

  • The back-end and code generators have been completely rewritten. GHC now uses an intermediate language that is closely based on C––, and from there it compiles to either C or native code, and in the future it will generate real C––. The only working native code generators right now are x86 and PowerPC; the Sparc native code generator has bitrotted in the rewrite.

    As part of this rewrite, we converted the parts of the RTS that were written in hand-coded .hc files into C–– code which is parsed and compiled by GHC itself. In theory this means you can bootstrap GHC without using the mangler at all, by compiling these files straight to native code. In practice, however, the native code generator in GHC isn't quite good enough yet to do this, and the RTS files have to be compiled via C.

  • Big changes to the way that declarations from interface files are read in, which should result in fewer interface files being read and therefore quicker compilation.

  • make -j8 now works for a full build of GHC.

  • GHC's documentation has now been converted from DocBook SGML to DocBook XML.

  • The config.h header file is now called ghcconfig.h.

  • The source tree has been cleaned up with respect to the use of _TARGET_OS vs. _HOST_OS and related symbols. The second stage build will now get the correct symbols defined. A comment at the top of mk/config.mk.in, where these symbols are defined, describes the ussage of these symbols in the source tree.

  • Blocking I/O in the threaded RTS is now done by a single I/O manager thread, which performs the blocking select() operation to wait for all outstanding I/O requests. Previously this was done in the RTS scheduler, but it is better to do this in Haskell because it is simpler, and results in fewer calls to select. (This change affects Unix platforms only).

  • Happy 1.15 is required to build GHC, as we now use the real parser to extract the module name and imports from a source file when doing initial dependency analysis of the program for ––make and GHCi. This requires a new feature in Happy (%partial) for parsing partial files.