
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually. (@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g

I've found myself using this quite a bit, actually; I strongly support
its addition to the Prelude or Control.Monad.
/g
On 10/28/06, Cale Gibbard
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries
-- It is myself I have never met, whose face is pasted on the underside of my mind.

trevion:
I've found myself using this quite a bit, actually; I strongly support its addition to the Prelude or Control.Monad.
/g
On 10/28/06, Cale Gibbard
wrote: Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
This does seem useful. However, the only way to make this actually happen is to submit a patch following this process: http://haskell.org/haskellwiki/Library_submissions otherwise, we'll just be about which colour we prefer for the bikeshed. I.e. * darcs patch * haddock comments * trac entry -- Don

Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly. My notation is (=>>=), to go with (>>=). Wolfram

On 2006-10-29 at 09:30EST kahl@cas.mcmaster.ca wrote:
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly.
My notation is (=>>=), to go with (>>=).
That's a better symbol for it. (@@) could be just about anything, while (=>>=) is suggestive. Though I think what it suggests might be with the arguments in a different order? -- Jón Fairbairn Jon.Fairbairn at cl.cam.ac.uk

On Sun, 2006-10-29 at 14:46 +0000, Jon Fairbairn wrote:
On 2006-10-29 at 09:30EST kahl@cas.mcmaster.ca wrote:
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly.
My notation is (=>>=), to go with (>>=).
That's a better symbol for it. (@@) could be just about anything, while (=>>=) is suggestive. Though I think what it suggests might be with the arguments in a different order?
Yes, we already have =<< for reverse >>= which is nice sometimes when you want to emphasise the similarity to (.) rather than imperative order, eg: return . foldr h z . map f . filter p =<< getContents So it'd be: (=<<=) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) (g =<<= f) x = g =<< f x (or should it really be written with a lambda?) and if there's demand for (=>>=) too then that's obviously easy to add. Duncan

On 2006-10-29 at 09:30EST kahl@cas.mcmaster.ca wrote:
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly.
My notation is (=>>=), to go with (>>=).
That's a better symbol for it. (@@) could be just about anything, while (=>>=) is suggestive. Though I think what it suggests might be with the arguments in a different order?
Yes, indeed! Thanks for pointing this out! And I definitely prefer that order: (=>>=) :: (a -> m b) -> (b -> m c) -> (a -> m c) Wolfram

On Sun, 2006-10-29 at 14:57 -0500, kahl@cas.mcmaster.ca wrote:
On 2006-10-29 at 09:30EST kahl@cas.mcmaster.ca wrote:
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly.
My notation is (=>>=), to go with (>>=).
That's a better symbol for it. (@@) could be just about anything, while (=>>=) is suggestive. Though I think what it suggests might be with the arguments in a different order?
Yes, indeed! Thanks for pointing this out! And I definitely prefer that order:
(=>>=) :: (a -> m b) -> (b -> m c) -> (a -> m c)
Ok. Let's have both (=>>=) and (=<<=). If that's a consensus, then someone make a darcs patch with haddock documentation and a trac bug etc. http://haskell.org/haskellwiki/Library_submissions Duncan

duncan.coutts:
On Sun, 2006-10-29 at 14:57 -0500, kahl@cas.mcmaster.ca wrote:
On 2006-10-29 at 09:30EST kahl@cas.mcmaster.ca wrote:
Speaking of small functions, Kleisli composition should at least be in Control.Monad. It's a simple thing, and not commonly explicitly used at the moment, but rather important conceptually.
(@@) :: (Monad m) => (b -> m c) -> (a -> m b) -> (a -> m c) g @@ f = \x -> f x >>= g
I support this strongly.
My notation is (=>>=), to go with (>>=).
That's a better symbol for it. (@@) could be just about anything, while (=>>=) is suggestive. Though I think what it suggests might be with the arguments in a different order?
Yes, indeed! Thanks for pointing this out! And I definitely prefer that order:
(=>>=) :: (a -> m b) -> (b -> m c) -> (a -> m c)
Ok. Let's have both (=>>=) and (=<<=).
If that's a consensus, then someone make a darcs patch with haddock documentation and a trac bug etc.
Before I or someone else rolls a patch for this, are there any other similar functions that fit? I'm reminded of some of the things from the old Gofer CC prelude, http://www.cse.unsw.edu.au/~dons/data/cc.prelude (@@) :: Monad m => (a -> m b) -> (c -> m a) -> (c -> m b) f @@ g = join . map f . g Do we have some references in the literature (a Mark Jones paper perhaps?) -- Don

hi, i also think that we should have kleisli composition, it is just as important as the ordinary composition. i do prefer the shorter (@@) notation though.
Before I or someone else rolls a patch for this, are there any other similar functions that fit?
I'm reminded of some of the things from the old Gofer CC prelude,
http://www.cse.unsw.edu.au/~dons/data/cc.prelude
(@@) :: Monad m => (a -> m b) -> (c -> m a) -> (c -> m b) f @@ g = join . map f . g
Do we have some references in the literature (a Mark Jones paper perhaps?)
are you think of a reference for kleisli composition? if so, it is a fairly standard operation and is described in many books and there is also a wikipedia entry for the kleisli category of a monad. kleisli composition should satisfy the usual properties of composition---associativity and left and right identity (using 'return')---and with the above definition these properties follow from the monad laws. -iavor

On 10/30/06, Donald Bruce Stewart
I'm reminded of some of the things from the old Gofer CC prelude,
http://www.cse.unsw.edu.au/~dons/data/cc.prelude
(@@) :: Monad m => (a -> m b) -> (c -> m a) -> (c -> m b) f @@ g = join . map f . g
Do we have some references in the literature (a Mark Jones paper perhaps?)
Indeed. "Functional Programming with Overloading and Higher-Order Polymorphism": http://web.cecs.pdx.edu/~mpj/pubs/springschool.html Page 31. Josef Svenningsson

kahl@cas.mcmaster.ca wrote:
... And I definitely prefer that order:
(=>>=) :: (a -> m b) -> (b -> m c) -> (a -> m c)
cultural note: it is one big problem to get the argument ordering for composition (of relations, including functions) "right". See any undergraduate textbook on how they confuse this. In fact, the root of the problem quite possibly is the idea that the function stands before its argument, which is contrary to the flow of information (and reading). There is one textbook http://www.infres.enst.fr/~jsaka/ETA/eta.html that takes the radical approach of writing not f(x) but x f. Then x(f.g) = (xf)g looks only natural. -- -- Johannes Waldmann -- Tel/Fax (0341) 3076 6479/80 -- ---- http://www.imn.htwk-leipzig.de/~waldmann/ -------

Johannes Waldmann wrote:
There is one textbook http://www.infres.enst.fr/~jsaka/ETA/eta.html that takes the radical approach of writing not f(x) but x f. Then x(f.g) = (xf)g looks only natural.
Those folks probably also put adjectives after their nouns. -- Ashley Yakeley Seattle WA

Hello kahl, Sunday, October 29, 2006, 5:30:41 PM, you wrote:
My notation is (=>>=), to go with (>>=).
and my is .>>= to reflect that it is like (.) i've used for years the following definitions: infixl 1 >>==, ==<<, =<<., .>>=, .>>, .>>==, ==<<. a>>==b = a >>= return.b a==<>=b) c = a c >>= b (a.>>b) c = a c >> b (a==<<.b) c = return.a =<< b c (a.>>==b) c = a c >>= return.b -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

On Sun, 29 Oct 2006, Bulat Ziganshin wrote:
Hello kahl,
Sunday, October 29, 2006, 5:30:41 PM, you wrote:
My notation is (=>>=), to go with (>>=).
and my is .>>= to reflect that it is like (.)
I have used this symbol for this purpose privately, too. However I also support (=>>=) and (=<<=).
participants (12)
-
Ashley Yakeley
-
Bulat Ziganshin
-
Cale Gibbard
-
dons@cse.unsw.edu.au
-
Duncan Coutts
-
Henning Thielemann
-
Iavor Diatchki
-
J. Garrett Morris
-
Johannes Waldmann
-
Jon Fairbairn
-
Josef Svenningsson
-
kahl@cas.mcmaster.ca