This is a guide to using the Glasgow Haskell compilation (GHC) system. It is a batch compiler for the Haskell 1.4 language, with support for various Glasgow-only extensions.
Many people will use GHC very simply: compile some
modules---ghc -c -O Foo.hs Bar.hs
; and link them---
ghc -o wiggle -O Foo.o Bar.o
.
But if you need to do something more complicated, GHC can do that, too:
ghc -c -O -fno-foldr-build -dcore-lint -fvia-C -ddump-simpl Foo.lhs
Stay tuned---all will be revealed!
In this document, we assume that GHC has been installed at your site
as ghc
. The rest of this section provide some tutorial information
on batch-style compilation; if you're familiar with these concepts
already, then feel free to skip to the next section.
The Glorious Haskell Compilation System, as with most UNIX (batch) compilation systems, has several interacting parts:
ghc
---which you
usually think of as ``the compiler''---is a program that merely
invokes/glues-together the other pieces of the system (listed below),
passing the right options to each, slurping in the right libraries,
etc.
unlit
that extracts Haskell
code from a literate script; used if you believe in that sort of
thing.
hscpp
,
only needed by people requiring conditional
compilation, probably for large systems. The ``Haskellised'' part
just means that #line
directives in the output have been
converted into proper Haskell {-# LINE ... -
} pragmas.
You must give an explicit -cpp
option
for the C pre-processor to be invoked.
hsc
,
which---in normal use---takes its input from the C pre-processor
and produces assembly-language output (sometimes: ANSI C output).
hsc
's C output into assembly language for a particular
target architecture. (It doesn't have to be an ANSI C compiler, but
that's preferred; to go fastest, you need GNU C, version 2.x.)
as
.
ld
.
You invoke the Glasgow Haskell compilation system through the
driver program ghc
.
For example, if you had typed a
literate ``Hello, world!'' program into hello.lhs
, and you then
invoked:
ghc hello.lhs
the following would happen:
hello.lhs
is run through the literate-program
code extractor unlit
, feeding its output to
hsc
, which produces
input for
a.out
.You have considerable control over the compilation process. You feed
command-line arguments (call them ``options,'' for short) to the
driver, ghc
; the ``types'' of the input files (as encoded in
their names' suffixes) also matter.
Here's hoping this is enough background so that you can read the rest of this guide!
On the World-Wide Web, there are several URLs of likely interest:
We run two mailing lists about Glasgow Haskell. We encourage you to join, as you feel is appropriate.
This list is for GHC users to chat among themselves. Subscribe by sending mail to majordomo@dcs.gla.ac.uk, with a message body (not header) like this:
subscribe glasgow-haskell-users MyName <m.y.self@@bigbucks.com>
(The last bit is your all-important e-mail address, of course.)
To communicate with your fellow users, send mail to glasgow-haskell-users@dcs.gla.ac.uk.
To contact the list administrator, send mail to glasgow-haskell-users-request@dcs.gla.ac.uk. An archive of the list is available on the Web: glasgow-haskell-users mailing list archive.
Send bug reports for GHC to this address! The sad and lonely people who subscribe to this list will muse upon what's wrong and what you might do about it.
Subscribe via majordomo@dcs.gla.ac.uk with:
subscribe glasgow-haskell-bugs My Name <m.y.self@@hackers.r.us>
Again, you may contact the list administrator at glasgow-haskell-bugs-request@dcs.gla.ac.uk. And, yes, an archive of the list is available on the Web at: : glasgow-haskell-bugs mailing list archive
There is also the general Haskell mailing list. Subscribe by sending email to majordomo@dcs.gla.ac.uk, with the usual message body:
subscribe haskell My Name <m.y.self@@fp.rules.ok.org>
Some Haskell-related discussion takes place in the Usenet newsgroup
comp.lang.functional
. (But note: news is basically dead at Glasgow.
That's one reason Glaswegians aren't too active in c.f.l.)
The main anonymous-FTP site for Glasgow Haskell is ftp://ftp.dcs.gla.ac.uk/pub/haskell/glasgow. ``Important'' bits are mirrored at other Haskell archive sites (and we have their stuff, too).
Changes made since 3.00:
floatExtreme.lc
.
NumExts
added and documented.
showOct
and showHex
from Numeric
to NumExts
.
QSort
into List
.
assert :: Bool -> a -> a
which has the following behaviour:
assert pred v
| pred = v
| otherwise = error "assertion failed"
However in this form, the practical use of assertions is
limited as no indication is given as to what assertion failed.
So to help out here, ghc will rewrite any uses of assert
to instead invoke the function assert__
:
assert__ :: String -> Bool -> a -> a
where the first argument to assert__
is a compiler generated string
which encodes the source location of the original assert
.
Assertions are a Glasgow extension, so -fglasgow-exts is
needed to use them.
-fwarn-unused-names
into
-fwarn-unused-imports
Warn about unused explicit imports. (in -W)
-fwarn-unused-binds
Warn about unused bindings (in -W)
-fwarn-unused-matches
Warn about unused names in pattern matches (not as useful, relegated to -Wall)
ghc-<version>
with a
link to it from ghc
.
ghc/lib/std -- all prelude files (libHS.a)
ghc/lib/std/cbits
ghc/lib/exts -- standard Hugs/GHC extensions (libHSexts.a)
-- available with '-fglasgow-exts'
ghc/lib/posix -- POSIX library (libHSposix.a)
ghc/lib/posix/cbits -- available with '-syslib posix'
ghc/lib/misc -- used to be hslibs/ghc (libHSmisc.a)
ghc/lib/misc/cbits -- available with '-syslib misc'
ghc/lib/concurrent -- Concurrent libraries (libHSconc.a)
-- available with '-concurrent'
Also, several non-standard prelude modules had their names changed to begin
with 'Prel' to reduce namespace pollution.
Addr ==> PrelAddr (Addr interface available in 'exts')
ArrBase ==> PrelArr
CCall ==> PrelCCall (CCall interface available in 'exts')
ConcBase ==> PrelConc
GHCerr ==> PrelErr
Foreign ==> PrelForeign (Foreign interface available in 'exts')
GHC ==> PrelGHC
IOHandle ==> PrelHandle
IOBase ==> PrelIOBase
GHCmain ==> PrelMain
STBase ==> PrelST
Unsafe ==> PrelUnsafe
UnsafeST ==> PrelUnsafeST
alpha-dec-osf1
and alpha-dec-osf3
are now separate
configurations. It turns out that an alpha-dec-osf3
build doesn't
work on older versions of the OS.