[Haskell-cafe] Why Kleisli composition is not in the Monad signature?
kdamodar2000 at gmail.com
Tue Oct 16 04:05:34 CEST 2012
In my opinion, this is not as nice as the do-notation version, but at
> least it's compositional:
That's an important point you have made, as Haskellers value code
composition so much.
If code composition is the "holy grail", why not encourage the monadic
code, too, to be compositional? Nicety can wait; some syntax sugar might
take care of it.
And as you have pointed out, arrows make a superior choice in this regard,
but they are rather newer to monads.
@ AUGER Cédric
It would be rather awful to expand each of your Kleisli arrows with
"const" as you said.
The const is required in this example because we are dealing with getLine
(as getLine can return different strings at different times without taking
any argument). Again, some syntactic sugar would have taken care of this
Correct me if I am wrong.
and thanks for responses.
On Mon, Oct 15, 2012 at 9:09 PM, Jake McArthur <jake.mcarthur at gmail.com>wrote:
> On Mon, Oct 15, 2012 at 11:33 AM, Jake McArthur <jake.mcarthur at gmail.com>
> > 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).
> My previous answer didn't do the Kleisli style much justice. It could
> look a bit nicer with more Arrow-style combinators:
> f &=& g = runKleisli $ Kleisli f &&& Kleisli g
> print <=< const getLine &=& const getLine $ ()
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe