How do I use multiple where clauses in GHCi?

Posted by T.R. on Stack Overflow See other posts from Stack Overflow or by T.R.
Published on 2010-06-18T07:35:46Z Indexed on 2010/06/18 7:43 UTC
Read the original article Hit count: 255

Filed under:
|

I'm playing around with GHCi for the first time, and I'm having some trouble writing multi-line functions. My code is as follows:

Prelude> :{
Prelude| let diffSquares lst = abs $ squareOfSums lst - sumOfSquares lst
Prelude|   where
Prelude|     squareOfSums lst = (fst (sumsAndSquares lst))^2
Prelude|     sumOfSquares lst = snd (sumsAndSquares lst)
Prelude|     sumsAndSquares = foldl (\(sms,sqrs) x -> (sms+x,sqrs+x^2)) (0,0)
Prelude| :}

It gives the following error:

<interactive>:1:142: parse error on input `='

Could someone kindly point me in the direction of what I'm missing?

© Stack Overflow or respective owner

Related posts about haskell

Related posts about ghci