next up previous
Next: Exercises Up: HaskellLab Previous: HaskellLab

Using ghci

By convention Haskell programs are written as text in a file with a .hs extension, e.g. lab.hs. I recommend having an editor window and an interpreter window open simultaneously. The updated program can be reloaded into ghci with :reload

To launch the Haskell interpreter, type ghci <fname> at the command line, e.g.

  linux34% ghci lab.hs
     ___         ___ _
    / _ \ /\  /\/ __(_)
   / /_\// /_/ / /  | |      GHC Interactive, version 5.04.2, for Haskell 98.
  / /_\\/ __  / /___| |      http://www.haskell.org/ghc/
  \____/\/ /_/\____/|_|      Type :? for help.
  
  Loading package base ... linking ... done.
  Loading package haskell98 ... linking ... done.
  Compiling Main             ( lab.hs, interpreted )
  
  lab.hs:1: Warning: No 'main' defined in module Main
  Ok, modules loaded: Main.
  *Main>
At the command line you can type expressions, e.g.
  *Main> length [1 .. 60]  
  60
  *Main>
or commands. Useful commands include

You can reuse many useful Haskell functions from the prelude (http://www.cs.uu.nl/ afie/haskell/tourofprelude.html) the standard libraries (http://www.haskell.org/onlinelibrary/), and other libraries (http://www.haskell.org/libraries/)



Phil Trinder 2003-10-22