On 12/18/05, Daniel Carrera <[EMAIL PROTECTED]> wrote: > Hello all, > > I'm trying to write the simplest possible Haskell program, and I'm not > getting anywhere. > > I have installed Hugs, GHC and GHCI. I want to run the following program: > > fac :: Integer -> Integer > fac 0 = 1 > fac n | n > 0 = n * fac (n-1) > > This is what I see: > > $ hugs > Hugs.Base> fac :: Integer -> Integer > ERROR - Undefined variable "fac" > Hugs.Base> fac 0 = 1 > ERROR - Syntax error in input (unexpected `=') > > > $ ghci > Prelude> fac :: Integer -> Integer > > <interactive>:1:0: Not in scope: `fac' > Prelude> fac 0 = 1 > <interactive>:1:6: parse error on input `=' > > $ # Write the program to fac.hs > $ ghc fac.hs > > fac.hs:1:0: > The main function `main' is not defined in module `Main' > When checking the type of the main function `main'
GHC is a compiler. If you want to compile to a binary then you must define a function called 'main'. Otherwise just load the file in ghci (`ghci fac.hs`). -- Friendly, Lemmih _______________________________________________ Haskell-Cafe mailing list [email protected] http://www.haskell.org/mailman/listinfo/haskell-cafe
