[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / docs / users_guide / intro.vsgml
1 <sect>Introduction to GHC
2 <label id="introduction-GHC">
3 <p>
4
5 This is a guide to using the Glasgow Haskell compilation (GHC) system.
6 It is a batch compiler for the Haskell~1.4 language, with support for
7 various Glasgow-only extensions.
8
9 Many people will use GHC very simply: compile some
10 modules---@ghc -c -O Foo.hs Bar.hs@; and link them---
11 @ghc -o wiggle -O Foo.o Bar.o@.
12
13 But if you need to do something more complicated, GHC can do that,
14 too:
15 <tscreen><verb>
16 ghc -c -O -fno-foldr-build -dcore-lint -fvia-C -ddump-simpl Foo.lhs
17 </verb></tscreen>
18 Stay tuned---all will be revealed!
19
20 In this document, we assume that GHC has been installed at your site
21 as @ghc@.  The rest of this section provide some tutorial information
22 on batch-style compilation; if you're familiar with these concepts
23 already, then feel free to skip to the next section.
24
25 %************************************************************************
26 %*                                                                      *
27 <sect1>The (batch) compilation system components
28 <label id="batch-system-parts">
29 <p>
30 %*                                                                      *
31 %************************************************************************
32
33 The Glorious Haskell Compilation System, as with most UNIX (batch)
34 compilation systems, has several interacting parts:
35 <enum>
36 <item>
37 A <em>driver</em><nidx>driver program</nidx> @ghc@<nidx>ghc</nidx>---which you
38 usually think of as ``the compiler''---is a program that merely
39 invokes/glues-together the other pieces of the system (listed below),
40 passing the right options to each, slurping in the right libraries,
41 etc.
42
43 <item>
44 A <em>literate pre-processor</em>
45 <nidx>literate pre-processor</nidx>
46 <nidx>pre-processor, literate</nidx>
47 @unlit@<nidx>unlit</nidx> that extracts Haskell
48 code from a literate script; used if you believe in that sort of
49 thing.
50
51 <item>
52 The <em>Haskellised C pre-processor</em>
53 <nidx>Haskellised C pre-processor</nidx>
54 <nidx>C pre-processor, Haskellised</nidx>
55 <nidx>pre-processor, Haskellised C</nidx>
56 @hscpp@,<nidx>hscpp</nidx> only needed by people requiring conditional
57 compilation, probably for large systems.  The ``Haskellised'' part
58 just means that @#line@ directives in the output have been
59 converted into proper Haskell @{-# LINE ... -@} pragmas.
60
61 You must give an explicit @-cpp@ option 
62 <nidx>-cpp option</nidx> for the C pre-processor to be invoked.
63
64 <item>
65 The <em>Haskell compiler</em>
66 <nidx>Haskell compiler</nidx>
67 <nidx>compiler, Haskell</nidx>
68 @hsc@,<nidx>hsc</nidx>
69 which---in normal use---takes its input from the C pre-processor
70 and produces assembly-language output (sometimes: ANSI C output).
71
72 <item>
73 The <em>ANSI~C Haskell high-level assembler :-)</em>
74 <nidx>ANSI C compiler</nidx>
75 <nidx>high-level assembler</nidx>
76 <nidx>assembler, high-level</nidx>
77
78 compiles @hsc@'s C output into assembly language for a particular
79 target architecture.  In fact, the only C compiler we currently
80 support is <tt/gcc/, because we make use of certain extensions to the
81 C language only supported by gcc.  Version 2.x is a must; we recommend
82 version 2.7.2.1 for stability (we've heard both good and bad reports
83 of later versions).
84
85 <item>
86 The <em>assembler</em><nidx>assembler</nidx>---a standard UNIX one, probably
87 @as@<nidx>as</nidx>.
88
89 <item>
90 The <em>linker</em><nidx>linker</nidx>---a standard UNIX one, probably
91 @ld@.<nidx>ld</nidx>
92
93 <item>
94 A <em>runtime system</em>,<nidx>runtime system</nidx> including (most notably)
95 a storage manager; the linker links in the code for this.
96
97 <item>
98 The <em>Haskell standard prelude</em><nidx>standard prelude</nidx>, a
99 large library of standard functions, is linked in as well.
100
101 <item>
102 Parts of other <em>installed libraries</em> that you have at your site
103 may be linked in also.
104 </enum>
105
106 %************************************************************************
107 %*                                                                      *
108 <sect1>What really happens when I ``compile'' a Haskell program?
109 <label id="compile-what-really-happens">
110 <p>
111 %*                                                                      *
112 %************************************************************************
113
114 You invoke the Glasgow Haskell compilation system through the
115 driver program @ghc@.<nidx>ghc</nidx> For example, if you had typed a
116 literate ``Hello, world!'' program into @hello.lhs@, and you then
117 invoked:
118 <tscreen><verb>
119 ghc hello.lhs
120 </verb></tscreen>
121
122 the following would happen:
123 <enum>
124 <item>
125 The file @hello.lhs@ is run through the literate-program
126 code extractor @unlit@<nidx>unlit</nidx>, feeding its output to
127
128 <item>
129 The Haskell compiler proper @hsc@<nidx>hsc</nidx>, which produces
130 input for
131
132 <item>
133 The assembler (or that ubiquitous ``high-level assembler,'' a C
134 compiler), which produces an object file and passes it to
135
136 <item>
137 The linker, which links your code with the appropriate libraries
138 (including the standard prelude), producing an executable program in
139 the default output file named @a.out@.
140 </enum>
141
142 You have considerable control over the compilation process.  You feed
143 command-line arguments (call them ``options,'' for short) to the
144 driver, @ghc@; the ``types'' of the input files (as encoded in
145 their names' suffixes) also matter.
146
147 Here's hoping this is enough background so that you can read the rest
148 of this guide!
149
150 % The ``style'' of the driver program @ghc@ follows that of the GNU C
151 % compiler driver @gcc@.  The use of environment variables to provide
152 % defaults is more extensive in this compilation system.
153
154 %--------------------------------------------------------------------
155 <sect1>Meta-information: Web sites, mailing lists, etc.
156 <label id="mailing-lists-GHC">
157 <p>
158 <nidx>mailing lists, Glasgow Haskell</nidx>
159 <nidx>Glasgow Haskell mailing lists</nidx>
160
161 On the World-Wide Web, there are several URLs of likely interest:
162
163 <itemize>
164 <item>  <url name="Haskell home page" url="http://haskell.org/">
165 <item>  <url name="GHC home page" url="http://www.dcs.gla.ac.uk/fp/software/ghc/">
166 <item>  <url name="Glasgow FP group page" url="http://www.dcs.gla.ac.uk/fp/">
167 <item>  <url name="comp.lang.functional FAQ" url="http://www.cs.nott.ac.uk/Department/Staff/mpj/faq.html">
168 </itemize>
169
170 We run two mailing lists about Glasgow Haskell.  We encourage you to
171 join, as you feel is appropriate.
172
173 <descrip>
174
175 <tag>glasgow-haskell-users:</tag>
176
177 This list is for GHC users to chat among themselves.  Subscribe by
178 sending mail to <htmlurl name="majordomo@@dcs.gla.ac.uk"
179 url="mailto:majordomo@@dcs.gla.ac.uk">, with a message body (not
180 header) like this:
181
182 <tscreen><verb> 
183 subscribe glasgow-haskell-users MyName <m.y.self@@bigbucks.com> 
184 </verb></tscreen> 
185
186 (The last bit is your all-important e-mail address, of course.)
187
188 To communicate with your fellow users, send mail to <url
189 name="glasgow-haskell-users@@dcs.gla.ac.uk"
190 url="mailto:glasgow-haskell-users@@dcs.gla.ac.uk">.
191
192 To contact the list administrator, send mail to <htmlurl
193 name="glasgow-haskell-users-request@@dcs.gla.ac.uk"
194 url="mailto:glasgow-haskell-users-request@@dcs.gla.ac.uk">.  An archive
195 of the list is available on the Web: <url name="glasgow-haskell-users
196 mailing list archive"
197 url="http://www.dcs.gla.ac.uk/mail-www/glasgow-haskell-users">.
198
199 <tag>glasgow-haskell-bugs:</tag>
200 Send bug reports for GHC to this address!  The sad and lonely people
201 who subscribe to this list will muse upon what's wrong and what you
202 might do about it.
203
204 Subscribe via <htmlurl name="majordomo@@dcs.gla.ac.uk"
205 url="mailto:majordomo@@dcs.gla.ac.uk"> with:
206
207 <tscreen><verb>
208 subscribe glasgow-haskell-bugs My Name <m.y.self@@hackers.r.us>
209 </verb></tscreen>
210
211 Again, you may contact the list administrator at <htmlurl
212 name="glasgow-haskell-bugs-request@@dcs.gla.ac.uk"
213 url="mailto:glasgow-haskell-bugs-request@@dcs.gla.ac.uk">.
214 And, yes, an archive of the list is available on the Web at: : <url
215 name="glasgow-haskell-bugs mailing list archive"
216 url="http://www.dcs.gla.ac.uk/mail-www/glasgow-haskell-bugs">
217
218 </descrip>
219
220 There is also the general Haskell mailing list.  Subscribe by sending
221 email to <htmlurl name="majordomo@@dcs.gla.ac.uk"
222 url="mailto:majordomo@@dcs.gla.ac.uk">, with the usual message body:
223
224 <tscreen><verb>
225 subscribe haskell My Name <m.y.self@@fp.rules.ok.org>
226 </verb></tscreen>
227
228 Some Haskell-related discussion takes place in the Usenet newsgroup
229 @comp.lang.functional@.  (But note: news is basically dead at Glasgow.
230 That's one reason Glaswegians aren't too active in c.f.l.)
231
232 The main anonymous-FTP site for Glasgow Haskell is <htmlurl
233 name="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow"
234 url="ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow">.  ``Important''
235 bits are mirrored at other Haskell archive sites (and we have their
236 stuff, too).