[Haskell-cafe] Chaining a map over lists with lenses
Michal Antkiewicz
mantkiew at gsd.uwaterloo.ca
Fri Oct 10 15:09:46 UTC 2014
The & is the same as $ with arguments inverted. So instead of
t & myField . traversed . otherField %~ (++ "X")
you could write
myField . traversed . otherField %~ (++ "X") $ t
(if I recall correctly...)
Michal
On Fri, Oct 10, 2014 at 11:03 AM, Nicola Gigante <nicola.gigante at gmail.com>
wrote:
>
> Il giorno 10/ott/2014, alle ore 16:36, Daniel Trstenjak <
> daniel.trstenjak at gmail.com> ha scritto:
>
> >
> > Hi Nicola,
> >
> > there's 'traversed' to access every entry of a traversable structure,
> > e.g. appending a "X" at the end of each 'otherField':
> >
> > t & myField . traversed . otherField %~ (++ "X")
> >
> >
> > And there's '^..' to return a list of each entry of a traversable
> structure:
> >
> > t ^.. myField . traversed . otherField
> >
>
> Thank you for both the answers!
>
> So my error was to presume that everything can be
> done with (^.) (which is view, if I’m correct).
>
> So I have to understand now, what is the & operator?
>
> >
> > Greetings,
> > Daniel
>
> Thank you,
> Nicola
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20141010/7c803533/attachment.html>
More information about the Haskell-Cafe
mailing list