I have just installed Haskell Platform for Windows (version 2011.2.0.1), and started to work through the HaskellQuestions.pdf
The second question requires "x = 3" as the answer. But when I enter this into GHCi I get
GHCi, version 7.0.3: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> x = 3
<interactive>:1:3: parse error on input `='
Prelude>
Why? I checked the answer, and I am right. Whats the matter with the equals sign?
In GHCi, to assign a value, you have to go
let x = 3
In regular Haskell code, x = 3
would be valid (see NB below).
Real World Haskell's Getting Started page has lots of useful info about using GHCI.
You can also look at the documentation for GHCi (but personally, I find Real World Haskell a little more digestable).
N.B. As EdvardM notes in the comments, the syntax for using let
in this context is from Haskell's do notation (if you're just beginning, don't stress yourself out if you're a little lost. Take your time, have fun, and it ought to make sense in no time).
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