Table of Contents
This section lists Glasgow Haskell infelicities in its implementation of Haskell 98. See also the “when things go wrong” section (Chapter 10, What to do when something goes wrong) for information about crashes, space leaks, and other undesirable phenomena.
The limitations here are listed in Haskell Report order (roughly).
Certain lexical rules regarding qualified identifiers
are slightly different in GHC compared to the Haskell
report. When you have
M.\, GHC will interpret it as a
single qualified operator rather than the two lexemes
GHC is a little less strict about the layout rule when used
do expressions. Specifically, the
restriction that "a nested context must be indented further to
the right than the enclosing context" is relaxed to allow the
nested context to be at the same level as the enclosing context,
if the enclosing context is a
For example, the following code is accepted by GHC:
main = do args <- getArgs if null args then return  else do ps <- mapM process args mapM print ps
GHC doesn't do fixity resolution in expressions during parsing. For example, according to the Haskell report, the following expression is legal Haskell:
let x = 42 in x == 42 == True
and parses as:
(let x = 42 in x == 42) == True
because according to the report, the
expression “extends as far to the right as
possible”. Since it can't extend past the second
equals sign without causing a parse error
== is non-fix), the
let-expression must terminate there. GHC
simply gobbles up the whole expression, parsing like this:
(let x = 42 in x == 42 == True)
The Haskell report is arguably wrong here, but nevertheless it's a difference between GHC & Haskell 98.
GHC's typechecker makes all pattern bindings monomorphic
by default; this behaviour can be disabled with
-XNoMonoPatBinds. See Section 7.1, “Language options”.
GHC requires the use of
files to cut the recursive loops among mutually recursive modules
as described in Section 4.7.9, “How to compile mutually recursive modules”. This more of an infelicity
than a bug: the Haskell Report says
(Section 5.7) "Depending on the Haskell
implementation used, separate compilation of mutually
recursive modules may require that imported modules contain
additional information so that they may be referenced before
they are compiled. Explicit type signatures for all exported
values may be necessary to deal with mutual recursion. The
precise details of separate compilation are not defined by
This code fragment should elicit a fatal error, but it does not:
main = print (array (1,1) [(1,2), (1,3)])
GHC's implementation of
array takes the value of an
array slot from the last (index,value) pair in the list, and does no
checking for duplicates. The reason for this is efficiency, pure and simple.
Tuples are currently limited to size 100. HOWEVER:
standard instances for tuples (
Show) are available
only up to 16-tuples.
This limitation is easily subvertible, so please ask if you get stuck on it.
GHC's implementation of the
Read class for integral types accepts
hexadecimal and octal literals (the code in the Haskell
98 report doesn't). So, for example,
read "0xf00" :: Int
works in GHC.
A possible reason for this is that
readLitChar accepts hex and
octal escapes, so it seems inconsistent not to do so for integers too.
The Haskell 98 definition of
isAlpha c = isUpper c || isLower c
GHC's implementation diverges from the Haskell 98
definition in the sense that Unicode alphabetic characters which
are neither upper nor lower case will still be identified as
Lazy I/O throws an exception if an error is
encountered, in contrast to the Haskell 98 spec which
requires that errors are discarded (see Section 21.2.2
of the Haskell 98 report). The exception thrown is
the usual IO exception that would be thrown if the
failing IO operation was performed in the IO monad, and can
be caught by
This section documents GHC's take on various issues that are left undefined or implementation specific in Haskell 98.
Following the ISO-10646 standard,
maxBound :: Char in GHC is
In GHC the
Int type follows the
size of an address on the host architecture; in other words
it holds 32 bits on a 32-bit machine, and 64-bits on a
fromInteger function (and hence
fromIntegral) is a special case when
Int. The value of
fromIntegral x :: Int is given by taking
n bits of
x), multiplied by the sign of
(in 2's complement
arithmetic). This behaviour was chosen so that for example
0xffffffff :: Int preserves the
bit-pattern in the resulting
Negative literals, such as
specified by (a careful reading of) the Haskell Report as
Prelude.negate (Prelude.fromInteger 3).
negate (fromInteger 2147483648).
fromInteger takes the lower 32 bits of the representation,
fromInteger (2147483648::Integer), computed at type
negate operation then
overflows, but it is unchecked, so
negate (-2147483648::Int) is just
-2147483648. In short, one can write
a literal with the expected meaning (but that is not in general guaranteed.
fromIntegral function also
preserves bit-patterns when converting between the sized
integral types (
Int64 and the unsigned
Word variants), see the modules
in the library documentation.
Double numbers are
unchecked for overflow, underflow, and
other sad occurrences. (note, however that some
architectures trap floating-point overflow and
loss-of-precision and report a floating-point exception,
probably terminating the