Expressing do block using only monadic bind syntax

Yes, all of them can be converted to bind syntax; in fact, they are converted internally by the compiler.

I hope this translation of your example gives you the hint:

main = readFile "foo.txt" >>= \f ->
       (print $ "prefix " ++ f) >>
       (print $ f ++ " postfix")

Leave a Comment