I'm going through the book Natural Language Processing for Working Programmers. The book uses Haskell, which I don't have much experience with. The code below throws an error in GHCI
:{
do
l <- [0..9]
ps <- (\x -> [x-1, x+2]) l
return ps
:}
This is the error message returned
The last statement in a 'do' construct must be an expression
All answers I've come across seem to suggest it is an indentation error, but as far as I can tell the indentation seems correct. Any ideas what the problem could be?
I typed your code into ghci 7.0.3 and did not get an error.
Prelude> :{
Prelude| do
Prelude| l <- [0..9]
Prelude| ps <- (\x -> [x-1, x+2]) l
Prelude| return ps
Prelude| :}
[-1,2,0,3,1,4,2,5,3,6,4,7,5,8,6,9,7,10,8,11]
Edit: When I use ghci 6.12.1 as packaged in Ubuntu 10.04, I get the same error as you.
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