I've downloaded WinHugs 2 hours ago and still can't figure out how to declare simple things. I'm trying to follow the book "7 languages in 7 weeks", but stuff like let x = 10
and double x = x * 2
gives syntax errors.
I'm not 100% sure what you're trying to do that doesn't work. You can't declare bindings in a WinHugs session, you can only evaluate full expressions. So you could do things like let x = 10 in x * x + x
, but you can't say let x = 10
in an interactive session. In other words, you can't make the declaration 'stick'.
To get around this, either put your declarations in a .hs
file and load it in WinHugs, or use GHCi instead (this is the better option, in my opinion - WinHugs is pretty dated). You can install GHCi by downloading Haskell Platform.
in winhugs the following gives a syntax error
let double x = x * 2
but the following works:
let double x = x * 2 in double 10
however in ghc they have the interactive environment ghci where everything works
let double x = x * 2
works
double 10
works
this link explains how to work with ghci environment: https://downloads.haskell.org/~ghc/7.2.2/docs/html/users_guide/interactive-evaluation.html
One minor issue is that on windows you need the presence of cygwin - otherwise ghci as compiled for windows will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With