[Haskell-cafe] First steps in Haskell
daniel.carrera at zmsl.com
Sun Dec 18 11:25:02 EST 2005
I'm trying to write the simplest possible Haskell program, and I'm not
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.Base> fac :: Integer -> Integer
ERROR - Undefined variable "fac"
Hugs.Base> fac 0 = 1
ERROR - Syntax error in input (unexpected `=')
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
The main function `main' is not defined in module `Main'
When checking the type of the main function `main'
This is a real problem for Haskell. I expect that a lot of people try
Haskell and give up because they can't even write the simplest function.
It's hard not to be put off by this. I love the theory behind Haskell,
but the practice of it seems to be a real problem.
I hope someone will show me how to make this program work. Even better,
I hope someone will fix the compilers and interpreters if they need
fixing, or fix the documentation if that's what needs fixing.
\/_/ I am not over-weight, I am under-tall.
More information about the Haskell-Cafe