
Hi All, I was wondering, why there isn't a composition operator for applicative functors. Of course it is rather trivial to implement, but it is a useful feature: {-# LANGUAGE FlexibleInstances, UndecidableInstances #-} module ApplicativeComposition where import Control.Applicative class (Applicative f) => ApplicativeComposition f where (<.>) :: f (b -> c) -> f (a -> b) -> f (a -> c) instance (Applicative f) => ApplicativeComposition f where (<.>) f g = pure (.) <*> f <*> g Can this be added to later versions of haskell? Greets, Edgar

On Fri, Oct 01, 2010 at 01:47:09AM +0200, edgar klerks wrote:
Hi All,
I was wondering, why there isn't a composition operator for applicative functors. Of course it is rather trivial to implement, but it is a useful feature:
I think you've answered your own question: it's rather trivial to implement. If we added every single useful function to the standard libraries, we'd be up to our necks.
{-# LANGUAGE FlexibleInstances, UndecidableInstances #-} module ApplicativeComposition where import Control.Applicative
class (Applicative f) => ApplicativeComposition f where (<.>) :: f (b -> c) -> f (a -> b) -> f (a -> c)
instance (Applicative f) => ApplicativeComposition f where (<.>) f g = pure (.) <*> f <*> g
Can this be added to later versions of haskell?
You can always make a formal proposal [1], although judging by past discussions of similar sorts of things I doubt it would be accepted, for the reasons I wrote above. Also, why bother making a new ApplicativeComposition type class? Since you can simply implement (<.>) in terms of existing Applicative methods the new type class doesn't really add anything. -Brent Footnotes: [1] http://www.haskell.org/haskellwiki/Library_submissions

On Friday 01 October 2010 11:48:19, David Virebayre wrote:
2010/10/1 Brent Yorgey
: I think you've answered your own question: it's rather trivial to implement. If we added every single useful function to the standard libraries, we'd be up to our necks.
You mean like in the container libraries ? :-P
Only much much worse 8-)
participants (4)
-
Brent Yorgey
-
Daniel Fischer
-
David Virebayre
-
edgar klerks