I thought I would spend some time this morning trying to learn Haskell. I happen to have downloaded a copy of WinHugs, and it seems to be functioning properly.
Alas, every function definition example I try to use blows up on me.
From: Beginning Haskell
Hugs> myNum :: Int
ERROR - Undefined variable “myNum”
Hugs> square :: Int -> Int
ERROR - Undefined variable “square”
Hugs> square n = n*n
ERROR - Syntax error in input (unexpected `=’)
Hmm, maybe the syntax is different? Looking at the WinHugs documentation, it says it is Haskell 98 compliant, except in some strange ways. Well, there’s always “Haskell in 5 steps”
Hugs> let fac n = if n == 0 then 1 else n * fac (n-1)
ERROR - Syntax error in expression (unexpected end of input)
Hugs> fac n = if n == 0 then 1 else n * fac (n-1)
ERROR - Syntax error in input (unexpected `=’)
Hmmm. Looking further at the Haskell in 5 steps, it seems like maybe I have to write the factorial program seperately, and load it into WinHugs? So I create fac.hs, and put it in:
C:\dev\haskell
C:
My Documents
C:\Program Files\WinHugs\
Can it find it in any of those locations? No. Even when I use the “Open” command from within WinHugs, it still can find fac.hs, even though I can clearly see it in my file explorer.
So I think that’s enough for one day.