getting started with the glasgow haskell compiler
Hello! I'm just getting started using the glasgow haskell compiler and when I try to compile a simple program, named Hello.lhs, like this: module Main (main) where main = 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?> Where can I find working example files? regards Mikael Johansson Control System Engineer Performance and control Volvo Aero Corporation Military Engines Trollhättan Dept. 7164MJ SE-461 81 Trollhättan, Sweden phone +46 520 940 61 e-mail: mikael.mj.johansson@volvo.com
Mikael Johansson writes:
module Main (main) where main = 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?>
.lhs means "literate Haskell file". Try
module Main (main) where main = putStrLn "Hello World"
(the "end" isn't legal Haskell). The ">" at the beginning of the line are called "Bird tracks" (after Richard Bird), and mark the lines of a literate Haskell program that are actually code. Lines without them are just comments. Or try \begin{code} module Main (main) where main = 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 file called Hello.hs rather than Hello.lhs. The .hs extension means "ordinary Haskell code". HTH. --KW 8-) -- Keith Wansbrough <kw217@cl.cam.ac.uk> http://www.cl.cam.ac.uk/users/kw217/ Cambridge University Computer Laboratory.
participants (2)
-
Johansson Mikael -
Keith Wansbrough