[Haskell-cafe] Why Kleisli composition is not in the Monad signature?
Benjamin Franksen
benjamin.franksen at helmholtz-berlin.de
Mon Oct 15 15:12:28 CEST 2012
Ertugrul Söylemez wrote:
> damodar kulkarni <kdamodar2000 at gmail.com> wrote:
>> The Monad class makes us define bind (>>=) and unit (return) for our
>> monads.
>>
>> Why the Kleisli composition (>=>) or (<=<) is not made a part of Monad
>> class instead of bind (>>=)?
>>
>> Is there any historical reason behind this?
>>
>> The bind (>>=) is not as elegant as (>=>), at least as I find it.
>>
>> Am I missing something?
>
> Try to express
>
> do x <- getLine
> y <- getLine
> print (x, y)
>
> using only Kleisli composition (without cheating). Through cheating
> (doing non-categorical stuff) it's possible to implement (>>=) in terms
> of (<=<), but as said that's basically breaking the abstraction.
What do you mean with "cheating" / "doing non-categorical stuff"?
m >>= f = (const m >=> f) ()
f >=> g = \x -> f x >>= g
How does the first definition "break the abstraction" while the second does
not?
Cheers
--
Ben Franksen
() ascii ribbon campaign - against html e-mail
/\ www.asciiribbon.org - against proprietary attachments
More information about the Haskell-Cafe
mailing list