ekmett/lens

Add a strict over?

Opened this issue · 1 comments

I don't see a strict version of over, which we could put in Control.Lens.Traversal.

over' :: ATraversal s t a b -> (a -> b) -> s -> t
over' l f = getSolo . cloneTraversal l (\old -> Solo $! f old)
  where
    getSolo (Solo x) = x

I don't remember how indexed stuff works, but I'm sure that's available too.

@phadej points out that this could alternatively take a LensLike Solo. I have no idea how to choose between that and ATraversal.