Fwd: [Haskell-beginners] Applicative Composition
Forwarding to list - it looks like I forgot to reply-all. ---------- Forwarded message ---------- From: Antoine Latter <aslatter@gmail.com> Date: Thu, Sep 30, 2010 at 7:17 PM Subject: Re: [Haskell-beginners] Applicative Composition To: edgar klerks <edgar.klerks@gmail.com> On Thu, Sep 30, 2010 at 6:47 PM, edgar klerks <edgar.klerks@gmail.com> 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:
{-# 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?
Here's the last time this topic came up on the lists: http://www.haskell.org/pipermail/libraries/2010-August/013992.html Here's the corresponding library proposal ticket: http://hackage.haskell.org/trac/ghc/ticket/4189 There were a few folks against it for a few different reasons. Antoine
Hi Brent and Antione, On Fri, Oct 1, 2010 at 3:41 AM, Brent Yorgey <byorgey@seas.upenn.edu> wrote:
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.
Ah yes I understand that. '
{-# 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.
Nopes I will refrain from that, I had to search first, before ask. My apologies for that, it was a bit late, when I posted it. And another thing is, that there are different implementations for such a operator. Better let the user create it themself. Thnx for the reply. Greets, Edgar On Fri, Oct 1, 2010 at 7:15 AM, Antoine Latter <aslatter@gmail.com> wrote:
Forwarding to list - it looks like I forgot to reply-all.
---------- Forwarded message ---------- From: Antoine Latter <aslatter@gmail.com> Date: Thu, Sep 30, 2010 at 7:17 PM Subject: Re: [Haskell-beginners] Applicative Composition To: edgar klerks <edgar.klerks@gmail.com>
On Thu, Sep 30, 2010 at 6:47 PM, edgar klerks <edgar.klerks@gmail.com> 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:
{-# 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?
Here's the last time this topic came up on the lists: http://www.haskell.org/pipermail/libraries/2010-August/013992.html
Here's the corresponding library proposal ticket: http://hackage.haskell.org/trac/ghc/ticket/4189
There were a few folks against it for a few different reasons.
Antoine _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
There was another small reason, I did ask it, because the applicative interface isn't as rich as the monad interface. I have read, that is because of historic reasons. They weren't in there at the beginning. But I really like to use applicative functors, if possible and this one seemed to be obvious, so I was a bit puzzeled, why it wasn't there. Are there any plans to enrich the interface for applicative functors? On Fri, Oct 1, 2010 at 11:03 AM, edgar klerks <edgar.klerks@gmail.com>wrote:
Hi Brent and Antione,
On Fri, Oct 1, 2010 at 3:41 AM, Brent Yorgey <byorgey@seas.upenn.edu>wrote:
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.
Ah yes I understand that. '
{-# 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.
Nopes I will refrain from that, I had to search first, before ask. My apologies for that, it was a bit late, when I posted it.
And another thing is, that there are different implementations for such a operator. Better let the user create it themself.
Thnx for the reply.
Greets,
Edgar
On Fri, Oct 1, 2010 at 7:15 AM, Antoine Latter <aslatter@gmail.com> wrote:
Forwarding to list - it looks like I forgot to reply-all.
---------- Forwarded message ---------- From: Antoine Latter <aslatter@gmail.com> Date: Thu, Sep 30, 2010 at 7:17 PM Subject: Re: [Haskell-beginners] Applicative Composition To: edgar klerks <edgar.klerks@gmail.com>
On Thu, Sep 30, 2010 at 6:47 PM, edgar klerks <edgar.klerks@gmail.com> 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:
{-# 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?
Here's the last time this topic came up on the lists: http://www.haskell.org/pipermail/libraries/2010-August/013992.html
Here's the corresponding library proposal ticket: http://hackage.haskell.org/trac/ghc/ticket/4189
There were a few folks against it for a few different reasons.
Antoine _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners
participants (2)
-
Antoine Latter -
edgar klerks