I am trying to declare local variables (is this the right term in the case of haskell?) in haskell using where and let-in clauses. However whenever my clauses are longer than a single line I always get some parse errors:
> letExample :: Int -> Int
> letExample 0 = 0
> letExample n =
> let one = 1
> four = 4
> eight = 8
> in one*four*eight
When trying to load the above code into ghci I get the following error:
letexample.lhs:4:33:
parse error in let binding: missing required 'in' Failed, modules loaded: none.
I get the following error when trying to load the code below:
whereexample:5:57: parse error on input ‘=’
Failed, modules loaded: none.
code:
> whereExample :: Int -> Int
> whereExample 0 = 0
> whereExample n = one * four * eight
> where one = 1
> four = 4
> eight = 8
What is the right way of using let and where in the above cases?