proposal #2461: add Traversable
generalizations?of?mapAccumL?and mapAccumR
Michael Karcher
usenet at mkarcher.dialup.fu-berlin.de
Mon Jul 28 04:48:34 EDT 2008
Conor McBride <conor at strictlypositive.org> wrote:
> Michael wrote
> > > David wrote (with patch applied):
[...]
> > > (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)
> I'm not saying the haddock is entirely clear, but it certainly
> doesn't necessitate the interpretation you're making.
OK, right. But the text "A variant of <*> with the arguments reversed"
at least sounds like "<**> = flip <*>", which obviously is untrue
then.
> Appearances can be deceptive, so why not actually try it?
I tried it, but too pure. I just checked whether some arguments
are somehow reversed, but didn't pay care to the effects:
*Main> runBackward $ (pure (++)) <*> (pure "Hello") <*> (pure " World")
"Hello World"
*Main> runBackward $ (pure (^)) <*> (pure 1) <*> (pure 2)
1
> *Backward> runBackward $ traverse (Backward . print) ["bong", "bing"]
> "bing"
> "bong"
> [(),()]
Thanks for the convincing example.
> In contrast with monads, the applicative interface does
> not offer the ability to make the choice of one computation
> depend on the value of another
Yeah, right. That's the point of Applicative, if I remember the
paper correctly.
> All the best
Thanks for the explanation.
Michael Karcher
More information about the Libraries
mailing list