Re:IO Monad Considered Harmful
by JoshTriplett on Friday January 23, 2015 @01:26AM
(#8933655)
Or:
foo = print =<< getLine
which often reads better when trying to build something that looks more like a nested function call and less like a pipeline.
Here's a function that has type `IO ()` but doesn't obviously use `IO`'s monadic interface.
`print` may use `IO`'s monadic interface under the hood, I don't know.Here's some code that has type `IO ()` and does use `IO`'s monadic interface.
which is de-sugared to which you can, if you like concise code, feel free to shorten to The important part is `>>=` (pronounced "bind"), which is defined in the monad typeclass. (A typeclass is like a Java interface, by the way.)