On Mon, Oct 14, 2013 at 6:51 PM, Kees Bleijenberg <k.bleijenberg@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