Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renaming stock lenses.

  • Loading branch information...
commit 4d32a26a7c16a5c1f24615e64d595f770e078f74 1 parent db2ace4
roconnor authored
38 src/Data/Lens/Common.hs
View
@@ -16,12 +16,12 @@ module Data.Lens.Common
, (^=), (^!=), (^%=), (^!%=), (^+=), (^!+=), (^-=), (^!-=), (^*=), (^!*=)
, (^/=), (^!/=), (^&&=), (^||=), (^!&&=), (^!||=)
-- * Stock lenses
- , fstLens
- , sndLens
- , mapLens
- , intMapLens
- , setLens
- , intSetLens
+ , fstL
+ , sndL
+ , mapL
+ , intMapL
+ , setL
+ , intSetL
) where
import Control.Applicative
@@ -98,35 +98,35 @@ Lens f `mergeL` Lens g =
Lens $ either (\a -> Left <$> f a) (\b -> Right <$> g b)
unzipL :: Lens a (b, c) -> (Lens a b, Lens a c)
-unzipL f = (fstLens . f, sndLens . f)
+unzipL f = (fstL . f, sndL . f)
-- * Stock lenses
-fstLens :: Lens (a,b) a
-fstLens = Lens $ \(a,b) -> store (\ a' -> (a', b)) a
+fstL :: Lens (a,b) a
+fstL = Lens $ \(a,b) -> store (\ a' -> (a', b)) a
-sndLens :: Lens (a,b) b
-sndLens = Lens $ \(a,b) -> store (\ b' -> (a, b')) b
+sndL :: Lens (a,b) b
+sndL = Lens $ \(a,b) -> store (\ b' -> (a, b')) b
-mapLens :: Ord k => k -> Lens (Map k v) (Maybe v)
-mapLens k = Lens $ \m -> store (\mv -> case mv of
+mapL :: Ord k => k -> Lens (Map k v) (Maybe v)
+mapL k = Lens $ \m -> store (\mv -> case mv of
Nothing -> Map.delete k m
Just v' -> Map.insert k v' m
) (Map.lookup k m)
-intMapLens :: Int -> Lens (IntMap v) (Maybe v)
-intMapLens k = Lens $ \m -> store (\mv -> case mv of
+intMapL :: Int -> Lens (IntMap v) (Maybe v)
+intMapL k = Lens $ \m -> store (\mv -> case mv of
Nothing -> IntMap.delete k m
Just v' -> IntMap.insert k v' m
) (IntMap.lookup k m)
-setLens :: Ord k => k -> Lens (Set k) Bool
-setLens k = Lens $ \m -> store (\mv ->
+setL :: Ord k => k -> Lens (Set k) Bool
+setL k = Lens $ \m -> store (\mv ->
if mv then Set.insert k m else Set.delete k m
) (Set.member k m)
-intSetLens :: Int -> Lens IntSet Bool
-intSetLens k = Lens $ \m -> store (\mv ->
+intSetL :: Int -> Lens IntSet Bool
+intSetL k = Lens $ \m -> store (\mv ->
if mv then IntSet.insert k m else IntSet.delete k m
) (IntSet.member k m)
6 src/Data/Lens/Multi/Common.hs
View
@@ -4,7 +4,7 @@ import Prelude hiding ((.), id)
import Control.Applicative
import Control.Applicative.Backwards
import Control.Category
-import Data.Lens.Common (Lens(..), fstLens, sndLens)
+import Data.Lens.Common (Lens(..), fstL, sndL)
import Data.Lens.Partial.Common (PartialLens, pLens, runPLens)
import Data.Lens.Mutator
import Control.Comonad
@@ -52,7 +52,7 @@ backPL :: MultiLens a b -> PartialLens a b
backPL = frontPL . reverseML
unzipML :: MultiLens a (b, c) -> (MultiLens a b, MultiLens a c)
-unzipML l = (totalML fstLens . l, totalML sndLens . l)
+unzipML l = (totalML fstL . l, totalML sndL . l)
isNullML :: MultiLens a b -> a -> Bool
isNullML l = null . getML l
@@ -69,7 +69,7 @@ lookupByML :: (k -> Bool) -> MultiLens [(k,v)] v
lookupByML p = partialML keyPL . listML
where
keyPL = pLens f
- f (k,v) | p k = right (runLens sndLens (k,v))
+ f (k,v) | p k = right (runLens sndL (k,v))
| otherwise = left (Identity (k,v))
lookupML :: (Eq k) => k -> MultiLens [(k,v)] v
4 src/Data/Lens/Partial/Common.hs
View
@@ -4,7 +4,7 @@ import Prelude hiding ((.), id, null, any, all)
import Control.Applicative
import Control.Category
import Control.Category.Product
-import Data.Lens.Common (Lens(..), fstLens, sndLens)
+import Data.Lens.Common (Lens(..), fstL, sndL)
import Data.Lens.Mutator
import Control.Comonad.Trans.Store
import Data.Foldable (any, all)
@@ -54,7 +54,7 @@ mergePL :: PartialLens a c -> PartialLens b c -> PartialLens (Either a b) c
PLens $ either (\a -> (fmap Left) <$> f a) (\b -> (fmap Right) <$> g b)
unzipPL :: PartialLens a (b, c) -> (PartialLens a b, PartialLens a c)
-unzipPL f = (totalPL fstLens . f, totalPL sndLens . f)
+unzipPL f = (totalPL fstL . f, totalPL sndL . f)
-- If the Partial is null.
isNullPL :: PartialLens a b -> a -> Bool
Please sign in to comment.
Something went wrong with that request. Please try again.