Generalized concatMap for lenses?

Previous Topic Next Topic
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Generalized concatMap for lenses?

Tyson Whitehead
I am writing some code to do some web-page parsing using the lens library.  The folded (or traverse) functions let me go

sequence -> lens fold

It would be nice to be able to go back again

lens fold -> sequence

The general idea being move it into a lens-fold sequence representation, work with it there, and then recover the original sequence representation.  As a more concrete example, the following works for lists

(folded .) :: Getter s [a] -> Fold s a

(to . toListOf) :: Fold s a -> Getter s [a]

I think I'm maybe thinking of something like a generalized concatMap for lenses

magic :: Fold s a -> Getter (f s) (f a)

Possibly there is already a function for this or some other way it should be done?  Haven't found it yet though, so thought I would ask the list for some enlightenment.

Thanks!  -Tyson
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
Only members subscribed via the mailman list are allowed to post.