The Haskell 98 Report contains the following example, in section 7.2 on
page 89:
main = readFile "input-file" >>= \ s ->
writeFile "output-file" (filter isAscii s) >>
putStr "Filtering succesful\n"
I am just learning Haskell, and this seemed extremely mysterious to me
until I realised that the \ s -> on the first line and the stuff before
the >> on the second line go together to make an expression of type
String -> IO String. In other words, it makes much more sense to me
when written as:
main = readFile "input-file" >>=
\ s -> writeFile "output-file" (filter isAscii s) >>
putStr "Filtering succesful\n"
My question is: is there some good reason why it is set out the way it
is in the report?
Cheers,
Greg O'Keefe