Browse files

applicative modify for parital lenses.

  • Loading branch information...
1 parent 672c998 commit ef2242b3d2334af46ff284a7081e06ba9165b123 @roconnor committed Apr 7, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/Data/Lens/Partial/Common.hs
View
7 src/Data/Lens/Partial/Common.hs
@@ -101,6 +101,13 @@ infixr 4 ^%=
(^%=) :: PartialLens a b -> (b -> b) -> a -> a
(^%=) = modPL
+infixr 4 ^%%=
+-- | applicative modify
+(^%%=) :: Applicative f => PartialLens a b -> (b -> f b) -> a -> f a
+PLens f ^%%= g = \a -> case f a of
+ Nothing -> pure a
+ Just (StoreT (Identity h) b) -> h <$> g b
+
-- * Pseudo-imperatives
infixr 4 ^+=, ^-=, ^*=

0 comments on commit ef2242b

Please sign in to comment.