@Jake

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 "const" thing.

Correct me if I am wrong. 

and thanks for responses.

Damodar

On Mon, Oct 15, 2012 at 9:09 PM, Jake McArthur <jake.mcarthur@gmail.com> wrote:
On Mon, Oct 15, 2012 at 11:33 AM, Jake McArthur <jake.mcarthur@gmail.com> wrote:
> On Mon, Oct 15, 2012 at 7:59 AM, Ertugrul Söylemez <es@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@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe