ekmett/lens — pull request #308 by glguy (2013-05-16 06:34:30+00:00)
Title: Effective instance for Indexing

Adding this instance allows us to satisfy the documented type of dropping as working on IndexedMonadicFolds, but it might not be the right solution as it requires the action to be run in the ReaderT Int m monad. (so I've submitted this as a pull request)

import Control.Applicative
import Control.Lens
import Control.Monad.IO.Class

printed :: (MonadIO m, Show a) => IndexPreservingAction m a a
printed = act (\x -> liftIO (print x) >> return x)

demo :: IO [Int]
demo = "abcd" ^!! dropping 1 (folded . printed . asIndex)