getting started with the glasgow haskell compiler

Keith Wansbrough [email protected]
Thu, 09 Aug 2001 10:37:04 +0100


Mikael Johansson writes:

> module Main (main) where
> main =3D putStrLn "Hello World"
> end
> =

> with the command
> =

> ghc Hello.lhs
> =

> I get the message on standard output:
> =

> No definitions in file <perhaps you forgot the '>'s?>


=2Elhs means "literate Haskell file".  Try


> module Main (main) where
> main =3D putStrLn "Hello World"

(the "end" isn't legal Haskell).  The ">" at the beginning of the line ar=
e called "Bird tracks" (after Richard Bird), and mark the lines of a lite=
rate Haskell program that are actually code.  Lines without them are just=
 comments.

Or try

\begin{code}
module Main (main) where
main =3D putStrLn "Hello World"
\end{code}

which is another way of marking code.

The final way, probably the easiest, is simply to put your program in a f=
ile called Hello.hs  rather than Hello.lhs.  The .hs extension means "ord=
inary Haskell code".

HTH.

--KW 8-)
-- =

Keith Wansbrough <[email protected]>
http://www.cl.cam.ac.uk/users/kw217/
Cambridge University Computer Laboratory.