Permalink
Browse files

Examples for (^?!)

  • Loading branch information...
1 parent 82aca33 commit 8bbeb9c3248c224b5528fc0d767216b463c5b0b9 @supki supki committed Mar 1, 2013
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/Control/Lens/Action.hs
@@ -101,6 +101,11 @@ a ^!! l = getEffect (l (Effect #. return . return) a)
-- | Perform a 'MonadicFold' and collect the leftmost result.
--
-- /Note:/ this still causes all effects for all elements.
+--
+-- >>> [Just 1, Just 2, Just 3]^!?folded.acts
+-- Just (Just 1)
+-- >>> [Just 1, Nothing]^!?folded.acts
+-- Nothing
(^!?) :: Monad m => s -> Acting m (Leftmost a) s t a b -> m (Maybe a)
a ^!? l = liftM getLeftmost .# getEffect $ l (Effect #. return . LLeaf) a
{-# INLINE (^!?) #-}

0 comments on commit 8bbeb9c

Please sign in to comment.