Thank you! I'm still lost in the forest of all lens functions and generality, and haven't expected this signature. Can someone recommend good reading on all the lens-related types and classes, what they represent and how can they be used? (interested not only in "how", but also "why")
The lens operator that does this is %%~, also called `traverseOf`:λ: ("Hello", "World") & _1 %%~ (\a -> putStrLn a >> return a)Hello("Hello","World")Also see the documentation: http://hackage.haskell.org/package/lens-4.4.0.1/docs/Control-Lens-Traversal.html#v:traverseOf--Benno2014-08-30 9:44 GMT+02:00 Nikolay Amiantov <nikoamia@gmail.com>:myOp lens f v = f (view lens v) >>= flip (set lens) vOf course I can write it myself, using combination of "view" and "set":in IO, where myOp would be of type:("Hello", "World") & _1 `myOp` (\a -> putStrLn a >> return a)Hello Cafe,I'm trying to wrap my head around 'lens' library. My current exercise is to modify something using Lens in monad. Say,
myOp :: Monad m => Lens s t a b -> (a -> m b) -> s -> m t
(have not checked this, but something like that should do), but is there a more elegant way?
Nikolay.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe