**Table of Contents**- 12.1. Haskell 98 vs. Glasgow Haskell: language non-compliance
- 12.2. Known bugs or infelicities

This section lists Glasgow Haskell infelicities in its implementation of Haskell 98. See also the “when things go wrong” section (Chapter 9) for information about crashes, space leaks, and other undesirable phenomena.

The limitations here are listed in Haskell Report order (roughly).

The Haskell report specifies that programs may be written using Unicode. GHC only accepts the ISO-8859-1 character set at the moment.

Certain lexical rules regarding qualified identifiers are slightly different in GHC compared to the Haskell report. When you have

*module*`.`, such as*reservedop*`M.\`, GHC will interpret it as a single qualified operator rather than the two lexemes`M`and`.\`.

GHC doesn't do fixity resolution in expressions during parsing. For example, according to the Haskell report, the following expression is legal Haskell:

and parses as:let x = 42 in x == 42 == True

because according to the report, the(let x = 42 in x == 42) == True

`let`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:

The Haskell report is arguably wrong here, but nevertheless it's a difference between GHC & Haskell 98.(let x = 42 in x == 42 == True)

None known.

None known.

None known.

- Multiply-defined array elements—not checked:
This code fragment

*should*elicit a fatal error, but it does not:main = print (array (1,1) [(1,2), (1,3)])

- The
`Char`type The Haskell report says that the

`Char`type holds 16 bits. GHC follows the ISO-10646 standard a little more closely:`maxBound :: Char`in GHC is`0x10FFFF`.- Arbitrary-sized tuples
Tuples are currently limited to size 100. HOWEVER: standard instances for tuples (

`Eq`,`Ord`,`Bounded`,`Ix``Read`, and`Show`) are available*only*up to 16-tuples.This limitation is easily subvertible, so please ask if you get stuck on it.

`Read`ing integersGHC's implementation of the

`Read`class for integral types accepts hexadeciaml and octal literals (the code in the Haskell 98 report doesn't). So, for example,

works in GHC.read "0xf00" :: Int

A possible reason for this is that

`readLitChar`accepts hex and octal escapes, so it seems inconsistent not to do so for integers too.

This section documents GHC's take on various issues that are left undefined or implementation specific in Haskell 98.

- Sized integral types
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 64-bit machine.Arithmetic on

`Int`is unchecked for overflow, so all operations on`Int`happen modulo 2^{n}whereis the size in bits of the*n*`Int`type.The

`fromInteger`function (and hence also`fromIntegral`) is a special case when converting to`Int`. The value of`fromIntegral x :: Int`is given by taking the lowerbits of*n*`(abs x)`, multiplied by the sign of`x`(in 2's complement-bit arithmetic). This behaviour was chosen so that for example writing*n*`0xffffffff :: Int`preserves the bit-pattern in the resulting`Int`.Negative literals, such as

`-3`, are specified by (a careful reading of) the Haskell Report as meaning`Prelude.negate (Prelude.fromInteger 3)`. So`-2147483648`means`negate (fromInteger 2147483648)`. Since`fromInteger`takes the lower 32 bits of the representation,`fromInteger (2147483648::Integer)`, computed at type`Int`is`-2147483648::Int`. The`negate`operation then overflows, but it is unchecked, so`negate (-2147483648::Int)`is just`-2147483648`. In short, one can write`minBound::Int`as a literal with the expected meaning (but that is not in general guaranteed.The

`fromIntegral`function also preserves bit-patterns when converting between the sized integral types (`Int8`,`Int16`,`Int32`,`Int64`and the unsigned`Word`variants), see the modules`Data.Int`and`Data.Word`in the library documentation.- Unchecked float arithmetic
Operations on

`Float`and`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 program).