Permalink
Browse files

adding reverseML and frontPL

  • Loading branch information...
1 parent 236aa8f commit e3ba801ee99101eeb42d1b35c705c0f721632728 @roconnor committed Jun 2, 2012
Showing with 7 additions and 0 deletions.
  1. +7 −0 src/Data/Lens/Multi/Common.hs
View
7 src/Data/Lens/Multi/Common.hs
@@ -2,6 +2,7 @@ module Data.Lens.Multi.Common where
import Prelude hiding ((.), id, null)
import Control.Applicative
+import Control.Applicative.Backwards
import Control.Category
import Data.Lens.Common (Lens(..))
import Data.Lens.Partial.Common (PartialLens, pLens, runPLens)
@@ -31,6 +32,12 @@ backPL :: MultiLens a b -> PartialLens a b
backPL (MLens f) = pLens $
coproduct left (right . uncurry store . (extract *** id) . runStoreT) . runStaredStore . f
+reverseML :: MultiLens a b -> MultiLens a b
+reverseML l = MLens (forwards . (l ^%%= (Backwards . runMLens id)))
+
+frontPL :: MultiLens a b -> PartialLens a b
+frontPL = backPL . reverseML
+
getML :: MultiLens a b -> a -> [b]
getML (MLens f) = poss . f

0 comments on commit e3ba801

Please sign in to comment.