10 Oct
2014
10 Oct
'14
9:58 a.m.
On Fri, Oct 10, 2014 at 9:21 AM, Nicola Gigante
t^.myField.something.otherField
I’m still trying to understand the full picture about lenses, but afaik what I need is a prism, because a list is a sum type, right?
`traverse` should do the trick. A traversal is like a lens, except it isn’t constrained to exactly one target. A prism is a traversal constrained to having exactly zero or one targets. `traverse` from `Data.Traversable` targets everything “in” the value. If you use `(^.)` with a traversal, though, that’ll require an instance of `Monoid` and it will in essence apply `mconcat` to the list of results. If you want them separately, try `(^..)` (pronounced `toListOf`, I believe).