[Haskell-beginners] monads do not fit together?
Kim-Ee Yeoh
ky3 at atamo.com
Mon Oct 14 12:57:49 UTC 2013
On Mon, Oct 14, 2013 at 6:51 PM, Kees Bleijenberg <
k.bleijenberg at lijbrandt.nl> wrote:
> The error at the problem line is: parse error on input `<-' ****
>
> If I move the line above the ’if’ I get: Couldn't match expected type
> `CGIT IO t0' with actual type `IO [String]'. ****
>
Looks like you're missing a "do". You're writing code like this:
if blah then
x <- foo
bar x
else
quux
when you need to write
if blah then do
x <- foo
bar x
else
quux
Recommended exercises:
* can you see in your mind's eye the desugaring of do-syntax?
* how would you write it in a single line, i.e. without using indentation
a.k.a. "layout" -- hint: look up curly braces
-- Kim-Ee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20131014/8e94857a/attachment.html>
More information about the Beginners
mailing list