«

»

Feb 26

Woke up this morning, had a blue moon in my eyes

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>