
Hi Mike as you perhaps have noticed, you use slightly different notations here:
file <- readFile "poem.txt"
let f = readFile “poem.txt”
You can run both versions in ghci, and if you take a look at the type signatures: λ> file <- readFile "poem.txt" λ> :t file file :: String λ> let f = readFile "poem.txt" λ> :t f f :: IO String You'll notice that f has type "IO String", whereas file only has type "String". So, to answer your second question: you can progress by using the "<-" notation, as in your haskell source code. To answer the first one: I'm not sure about ghci command prompt, but I would expect, that it is equivalent to "main = do ...". That is, the type error you got, is not due to ghci and main = do are different, but because you used to different types. To understand the "<-" notation, the example from Learn you a Haskell was quite good for me: Try to see types like "IO String" as an action or box, which can result in a string. You can take the inner type out of the box, by using "<-". Hope that helps, cheers, Friedrich