[project @ 2000-03-15 15:03:20 by simonmar]
[ghc-hetmet.git] / ghc / docs / users_guide / vs_haskell.sgml
1 <Sect1 id="vs-Haskell-defn">
2 <Title>Haskell&nbsp;98 vs.&nbsp;Glasgow Haskell: language non-compliance
3 </Title>
4
5 <Para>
6 <IndexTerm><Primary>GHC vs the Haskell 98 language</Primary></IndexTerm>
7 <IndexTerm><Primary>Haskell 98 language vs GHC</Primary></IndexTerm>
8 </Para>
9
10 <Para>
11 This section lists Glasgow Haskell infelicities in its implementation
12 of Haskell&nbsp;98.  See also the &ldquo;when things go wrong&rdquo; section
13 (<XRef LinkEnd="wrong">)
14 for information about crashes, space leaks, and other undesirable
15 phenomena.
16 </Para>
17
18 <Para>
19 The limitations here are listed in Haskell-Report order (roughly).
20 </Para>
21
22 <Sect2 id="infelicities-exprs-pats">
23 <Title>Expressions and patterns
24 </Title>
25
26 <Para>
27 <VariableList>
28
29 <VarListEntry>
30 <Term>Very long <Literal>String</Literal> constants:</Term>
31 <ListItem>
32 <Para>
33 May not go through.  If you add a &ldquo;string gap&rdquo; every
34 few thousand characters, then the strings can be as long
35 as you like.
36 </Para>
37
38 <Para>
39 Bear in mind that string gaps and the <Option>-cpp</Option><IndexTerm><Primary>-cpp option</Primary></IndexTerm>
40 option don't mix very well (see <XRef LinkEnd="c-pre-processor">).
41 </Para>
42 </ListItem>
43 </VarListEntry>
44 <VarListEntry>
45 <Term>Very long literal lists:</Term>
46 <ListItem>
47 <Para>
48 These may tickle a &ldquo;yacc stack overflow&rdquo; error in the parser.
49 (It depends on the Yacc used to build your parser.)
50 </Para>
51 </ListItem>
52 </VarListEntry>
53 <VarListEntry>
54 <Term>Single quotes in module names:</Term>
55 <ListItem>
56 <Para>
57 It might work, but it's just begging for trouble.
58 </Para>
59 </ListItem>
60 </VarListEntry>
61 </VariableList>
62 </Para>
63
64 </Sect2>
65
66 <Sect2 id="infelicities-decls">
67 <Title>Declarations and bindings
68 </Title>
69
70 <Para>
71 <VariableList>
72
73 <VarListEntry>
74 <Term>Derived instances for records:</Term>
75 <ListItem>
76 <Para>
77 Hmmm.
78 </Para>
79 </ListItem>
80 </VarListEntry>
81 </VariableList>
82 </Para>
83
84 </Sect2>
85
86 <Sect2 id="infelicities-Modules">
87 <Title>Module system and interface files
88 </Title>
89
90 <Para>
91 <VariableList>
92
93 <VarListEntry>
94 <Term> Namespace pollution </Term>
95 <ListItem>
96 <Para>
97 Several modules internal to GHC are visible in the standard namespace.
98 All of these modules begin with <Literal>Prel</Literal>, so the rule is: don't use any
99 modules beginning with <Literal>Prel</Literal> in your program, or you will be
100 comprehensively screwed.
101 </Para>
102 </ListItem>
103 </VarListEntry>
104 </VariableList>
105 </Para>
106
107 </Sect2>
108
109 <Sect2 id="infelicities-numbers">
110 <Title>Numbers, basic types, and built-in classes
111 </Title>
112
113 <Para>
114 <VariableList>
115
116 <VarListEntry>
117 <Term>Unchecked arithmetic:</Term>
118 <ListItem>
119 <Para>
120 Arguably <Emphasis>not</Emphasis> an infelicity, but&hellip; Bear in mind that
121 operations on <Literal>Int</Literal>, <Literal>Float</Literal>, and <Literal>Double</Literal> numbers are
122 <Emphasis>unchecked</Emphasis> for overflow, underflow, and other sad occurrences.
123 (note, however that some architectures trap floating-point overflow
124 and loss-of-precision and report a floating-point
125 exception)<IndexTerm><Primary>floating-point exceptions</Primary></IndexTerm>.
126 </Para>
127
128 <Para>
129 Use <Literal>Integer</Literal>, <Literal>Rational</Literal>, etc., numeric types if this stuff
130 keeps you awake at night.
131 </Para>
132 </ListItem>
133 </VarListEntry>
134 <VarListEntry>
135 <Term>Multiply-defined array elements&mdash;not checked:</Term>
136 <ListItem>
137 <Para>
138 This code fragment <Emphasis>should</Emphasis> elicit a fatal error, but it does not:
139
140 <ProgramListing>
141 main = print (array (1,1) [ 1:=2, 1:=3 ])
142 </ProgramListing>
143
144 </Para>
145 </ListItem>
146 </VarListEntry>
147 </VariableList>
148 </Para>
149
150 </Sect2>
151
152 <Sect2 id="infelicities-Prelude">
153 <Title>In Prelude support
154 </Title>
155
156 <Para>
157 <VariableList>
158
159 <VarListEntry>
160 <Term>Arbitrary-sized tuples:</Term>
161 <ListItem>
162 <Para>
163 Plain old tuples of arbitrary size <Emphasis>do</Emphasis> work.
164 </Para>
165
166 <Para>
167 HOWEVER: standard instances for tuples (<Literal>Eq</Literal>, <Literal>Ord</Literal>, <Literal>Bounded</Literal>, <Literal>Ix</Literal>
168 <Literal>Read</Literal>, and <Literal>Show</Literal>) are available <Emphasis>only</Emphasis> up to 5-tuples.
169 </Para>
170
171 <Para>
172 These limitations are easily subvertible, so please ask if you get
173 stuck on them.
174 </Para>
175 </ListItem>
176 </VarListEntry>
177 <VarListEntry>
178 <Term>Unicode character set:</Term>
179 <ListItem>
180 <Para>
181 Haskell 98 embraces the Unicode character set, but GHC doesn't
182 handle it. Yet.
183 </Para>
184 </ListItem>
185 </VarListEntry>
186 </VariableList>
187 </Para>
188
189 </Sect2>
190
191 </Sect1>