[Haskell-cafe] Generalized concatMap for lenses?

Tyson Whitehead twhitehead at gmail.com
Sat May 6 21:40:17 UTC 2017

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

More information about the Haskell-Cafe mailing list