proposal #2461: add Traversable generalizations
of?mapAccumL?and mapAccumR
Michael Karcher
usenet at mkarcher.dialup.fu-berlin.de
Mon Jul 28 02:50:29 EDT 2008
David Menendez <dave at zednenem.com> wrote:
> On Fri, Jul 25, 2008 at 10:12 AM, Michael Karcher
> <usenet at mkarcher.dialup.fu-berlin.de> wrote:
> > David Menendez <dave at zednenem.com> wrote:
> >> Incidentally, is there a Backward applicative functor transfomer
> >> defined anywhere?
> >>
> >> newtype Backward f a = Backward { runBackward :: f a } deriving Functor
> >>
> >> instance Applicative f => Applicative (Backward f) where
> >> pure = Backward . pure
> >> (Backward f) <*> (Backward a) = Backward (f <**> a)
> >
> > My intuitive typechecker doesn't accept that. And GHCi 6.8.2 seems to agree
> > (I had to enable GeneralizedNewtypeDeriving for obvious reasons).
> [..]
> > Did I misunderstand something?
>
> That's a typo on my part. I should have written "Backward (a <**> f)".
so you mean:
Backward f <*> Backward a = Backward (a <**> f)
?
According to the haddock of Control.Applicative, this line is semantically
equivalent to
Backward f <*> Backward a = Backward (f <*> a)
So I don't see the point of this "transformer". It seems to do nothing, just
as
newtype Backward f a = Backward { runBackward :: f a }
deriving (Functor, Applicative)
would also do.
Regards,
Michael Karcher
More information about the Libraries
mailing list