[Haskell-cafe] Why Kleisli composition is not in the Monad signature?

Jake McArthur jake.mcarthur at gmail.com
Mon Oct 15 17:33:30 CEST 2012

On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez <es at ertes.de> wrote:
> Try to express
>     do x <- getLine
>        y <- getLine
>        print (x, y)
> using only Kleisli composition (without cheating).

In my opinion, this is not as nice as the do-notation version, but at
least it's compositional:

    print <=< (<$> getLine) . (,) <=< const getLine $ ()

I do think there is value in favoring Kleisli composition for a lot of
code. Unfortunately, however, it doesn't tend to work out so nicely
for IO.

- Jake

More information about the Haskell-Cafe mailing list