Fri Nov 19 1999, Greg O'Keefe ->
> 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?

The style in the Haskell report (and the design of the >>= operator) is
meant to symbolize that the value bound to s comes from the first
expression.

        n.

-- 
[ http://www.dtek.chalmers.se/~d95mback/ ] [ PGP: 0x453504F1 ] [ UIN: 4439498 ]
    Opinions expressed above are mine, and not those of my future employees.
                  Skingra er! Det finns ingenting att f�rst�!

PGP signature

Reply via email to