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.reservedop, such as 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:
let x = 42 in x == 42 == True |
(let x = 42 in x == 42) == True |
(let x = 42 in x == 42 == True) |
May not go through. If you add a “string gap” every few thousand characters, then the strings can be as long as you like.
Bear in mind that string gaps and the -cpp option don't mix very well (see Section 4.12.3).
None known.
Several modules internal to GHC are visible in the standard namespace. All of these modules begin with Prel, so the rule is: don't use any modules beginning with Prel in your program, or you will be comprehensively screwed.
This code fragment should elicit a fatal error, but it does not:
main = print (array (1,1) [(1,2), (1,3)]) |
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.
Tuples are currently limited to size 61. HOWEVER: standard instances for tuples (Eq, Ord, Bounded, Ix Read, and Show) are available only up to 5-tuples.
This limitation is easily subvertible, so please ask if you get stuck on it.
This section documents GHC's take on various issues that are left undefined or implementation specific in Haskell 98.
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 2n where n is the size in bits of the Int type.
The fromIntegerfunction (and hence also fromIntegral) is a special case when converting to Int. The value of fromIntegral x :: Int is given by taking the lower n bits of (abs x), multiplied by the sign of x (in 2's complement n-bit arithmetic). This behaviour was chosen so that for example writing 0xffffffff :: Int preserves the bit-pattern in the resulting Int.
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).