lens-family 2.0.0 → 2.1.3
raw patch · 5 files changed
Files
- CHANGELOG +22/−0
- lens-family.cabal +9/−8
- src/Lens/Family2.hs +3/−3
- src/Lens/Family2/Stock.hs +64/−28
- src/Lens/Family2/Unchecked.hs +7/−7
CHANGELOG view
@@ -1,3 +1,25 @@+2.1.3 (Changes from 2.1.2)+=========================+* Bump dependency on containers.++2.1.2 (Changes from 2.1.1)+==========================+* Bump dependency on transformers and mtl++2.1.1 (Changes from 2.1.0)+==========================+This release makes the library forwards compatable with GHC 9.++2.1.0 (Changes from 2.0.0)+==========================+This release makes some minor name changes to functions.++* 'lft' and 'rgt' have been renamed as 'left' and 'right'.+* 'some' and 'none' have been renamed as 'just' and 'nothing'.+* Similar name changes for the lens variants of the above prisms.++The old names are depricated and may be removed in the future.+ 2.0.0 (Changes from 1.2.4) ========================== This new release continues to explore the design of Van Laarhoven style
lens-family.cabal view
@@ -1,11 +1,11 @@ name: lens-family category: Data, Lenses-version: 2.0.0+version: 2.1.3 license: BSD3-cabal-version: >= 1.6+cabal-version: >= 1.10 license-file: LICENSE author: Russell O'Connor-maintainer: Russell O'Connor <roconnor@theorem.ca>+maintainer: Russell O'Connor <roconnor@r6.ca> stability: experimental copyright: Copyright (C) 2012,2013,2014,2017,2018,2019 Russell O'Connor synopsis: Lens Families@@ -40,13 +40,14 @@ location: https://hub.darcs.net/roconnor/lens-family library- extensions: Rank2Types+ default-language: Haskell2010+ other-extensions: Rank2Types build-depends: base >= 4.11 && < 5,- containers >= 0.5.8 && < 0.7,- transformers >= 0.3.0 && < 0.6,- mtl >= 2.2 && < 2.3,- lens-family-core >= 2.0.0 && < 2.1+ containers >= 0.5.8 && < 0.8,+ transformers >= 0.3.0 && < 0.7,+ mtl >= 2.2 && < 2.4,+ lens-family-core >= 2.1.0 && < 2.2 exposed-modules: Lens.Family2.Unchecked
src/Lens/Family2.hs view
@@ -69,7 +69,7 @@ -- -- | 'zipWithOf' can be used with grates to zip two structure together provided a binary operation. ----- 'under' can be to modify each value in a structure according to a function. This works analogous to how 'over' works for lenses and traversals.+-- 'under' can be used to modify each value in a structure according to a function. This works analogous to how 'over' works for lenses and traversals. -- -- 'LF.review' can be used with grates to construct a constant grate from a single value. This is like a 0-ary @zipWith@ function. --@@ -193,13 +193,13 @@ -- >>> (3 :+ 4, "example")^._1.to(abs) -- 5.0 :+ 0.0 to :: (s -> a) -> Getter s t a b-to = LF.to+to sa = LF.to sa -- | 'folding' promotes a \"toList\" function to a read-only traversal called a fold. -- -- To demote a traversal or fold to a \"toList\" function use the section @(^..l)@ or @toListOf l@. folding :: Foldable f => (s -> f a) -> Fold s t a b-folding = LF.folding+folding sa = LF.folding sa -- | Returns a list of all of the referenced values in order. toListOf :: Fold s t a b -> s -> [a]
src/Lens/Family2/Stock.hs view
@@ -13,8 +13,8 @@ , at', intAt' , contains, intContains -- * Stock Prisms- , lft, rgt- , some, none+ , left, right+ , just, nothing -- * Stock Grids , both , bend, lend@@ -25,8 +25,8 @@ -- * Stock Traversals , both_ , bend_, lend_- , lft_, rgt_- , some_, none_+ , left_, right_+ , just_, nothing_ , ignored -- * Stock SECs , mapped@@ -48,6 +48,11 @@ , Stock.LensLike, Stock.LensLike' , Stock.Identical, Stock.Backwards , Stock.FiniteBits+-- * Deprecated names+ , lft, rgt+ , some, none+ , lft_, rgt_+ , some_, none_ ) where import qualified Data.Map as Map@@ -71,68 +76,67 @@ -- | Lens on a given point of a function. ix :: Eq k => k -> Lens' (k -> v) v-ix = Stock.ix+ix k = Stock.ix k -- | Lens on a given point of a 'Map.Map'. at :: Ord k => k -> Lens' (Map.Map k v) (Maybe v)-at = Stock.at+at k = Stock.at k -- | Lens on a given point of a 'IntMap.IntMap'. intAt :: Int -> Lens' (IntMap.IntMap v) (Maybe v)-intAt = Stock.intAt+intAt i = Stock.intAt i -- | Lens providing strict access to a given point of a 'Map.Map'. at' :: Ord k => k -> Lens' (Map.Map k v) (Maybe v)-at' = Stock.at'+at' k = Stock.at' k -- | Lens providing strict access to a given point of a 'IntMap.IntMap'. intAt' :: Int -> Lens' (IntMap.IntMap v) (Maybe v)-intAt' = Stock.intAt'+intAt' i = Stock.intAt' i -- | Lens on a given point of a 'Set.Set'. contains :: Ord k => k -> Lens' (Set.Set k) Bool-contains = Stock.contains+contains k = Stock.contains k -- | Lens on a given point of a 'IntSet.IntSet'. intContains :: Int -> Lens' IntSet.IntSet Bool-intContains = Stock.intContains+intContains i = Stock.intContains i -- | A grate accessing the codomain of a function. cod :: Grate (r -> a) (r -> b) a b cod = Stock.cod -- | A prism on the 'Left' element of an 'Either'.-lft :: Prism (Either a r) (Either b r) a b-lft = Stock.lft+left :: Prism (Either a r) (Either b r) a b+left = Stock.left -- | Traversal on the 'Left' element of an 'Either'.-lft_ :: Traversal (Either a r) (Either b r) a b-lft_ = Stock.lft_+left_ :: Traversal (Either a r) (Either b r) a b+left_ = Stock.left_ -- | A prism on the 'Right' element of an 'Either'.-rgt :: Prism (Either r a) (Either r b) a b-rgt = Stock.rgt+right :: Prism (Either r a) (Either r b) a b+right = Stock.right -- | Traversal on the 'Right' element of an 'Either'.-rgt_ :: Traversal (Either r a) (Either r b) a b-rgt_ = Stock.rgt_-+right_ :: Traversal (Either r a) (Either r b) a b+right_ = Stock.right_ -- | A prism on the 'Just' element of a 'Maybe'.-some :: Prism (Maybe a) (Maybe b) a b-some = Stock.some+just :: Prism (Maybe a) (Maybe b) a b+just = Stock.just -- | Traversal on the 'Just' element of a 'Maybe'.-some_ :: Traversal (Maybe a) (Maybe b) a b-some_ = Stock.some_+just_ :: Traversal (Maybe a) (Maybe b) a b+just_ = Stock.just_ -- | A prism on the 'Nothing' element of a 'Maybe'.-none :: Prism' (Maybe a) ()-none = Stock.none+nothing :: Prism' (Maybe a) ()+nothing = Stock.nothing -- | Traversal on the 'Nothing' element of a 'Maybe'.-none_ :: Traversal' (Maybe a) ()-none_ = Stock.none_+nothing_ :: Traversal' (Maybe a) ()+nothing_ = Stock.nothing_ -- | A grid on both elements of a pair @(a,a)@. both :: Grid (a,a) (b,b) a b@@ -189,3 +193,35 @@ -- | An SEC referencing the parameter of a functor. mapped :: Functor f => Setter (f a) (f a') a a' mapped = Stock.mapped++{-# DEPRECATED lft "Renamed as 'left'." #-}+lft :: Prism (Either a r) (Either b r) a b+lft = left++{-# DEPRECATED lft_ "Renamed as 'left_'." #-}+lft_ :: Traversal (Either a r) (Either b r) a b+lft_ = left_++{-# DEPRECATED rgt "Renamed as 'right'." #-}+rgt :: Prism (Either r a) (Either r b) a b+rgt = right++{-# DEPRECATED rgt_ "Renamed as 'right_'." #-}+rgt_ :: Traversal (Either r a) (Either r b) a b+rgt_ = right_++{-# DEPRECATED some "Renamed as 'just'." #-}+some :: Prism (Maybe a) (Maybe b) a b+some = just++{-# DEPRECATED some_ "Renamed as 'just_'." #-}+some_ :: Traversal (Maybe a) (Maybe b) a b+some_ = just_++{-# DEPRECATED none "Renamed as 'nothing'." #-}+none :: Prism' (Maybe a) ()+none = nothing++{-# DEPRECATED none_ "Renamed as 'nothing_'." #-}+none_ :: Traversal' (Maybe a) ()+none_ = nothing_
src/Lens/Family2/Unchecked.hs view
@@ -148,7 +148,7 @@ -- -- /Note/: It is possible to build grates without even depending on @lens-family@ by expanding away the type synonym. ----- > myStream :: Functor g => (g (Stream a) -> Stream b) -> g a -> b+-- > myStream :: Functor g => (g a -> b) -> g (Stream a) -> (Stream b) -- -- Any value @t :: Grate s t a b@ is a well-defined grate when it satisfies the two van Laarhoven traversal laws: --@@ -242,7 +242,7 @@ adapter :: (s -> a) -- ^ yin -> (b -> t) -- ^ yang -> Adapter s t a b-adapter = LF.adapter+adapter sa bt = LF.adapter sa bt -- | Build a lens from a @getter@ and @setter@ family. --@@ -256,7 +256,7 @@ lens :: (s -> a) -- ^ getter -> (s -> b -> t) -- ^ setter -> Lens s t a b-lens = LF.lens+lens sa sbt = LF.lens sa sbt grate :: (((s -> a) -> b) -> t) -- ^ grater -> Grate s t a b@@ -269,7 +269,7 @@ -- * @grater (\k -> h (k . grater)) === grater (\k -> h ($ k))@ -- -- Note: The grater laws are that of an algebra for the parameterised continuation monad, `Lens.Family.PCont`.-grate = LF.grate+grate sabt = LF.grate sabt -- | Build a prism from a @matcher@ and @reviewer@ family. --@@ -283,7 +283,7 @@ prism :: (s -> Either t a) -- ^ matcher -> (b -> t) -- ^ reviewer -> Prism s t a b-prism = LF.prism+prism sta bt = LF.prism sta bt -- | 'setting' promotes a \"semantic editor combinator\" to a modify-only lens. -- To demote a lens to a semantic edit combinator, use the section @(l %~)@ or @over l@ from "Lens.Family2".@@ -298,7 +298,7 @@ -- * @sec f . sec g === sec (f . g)@ setting :: ((a -> b) -> s -> t) -- ^ sec (semantic editor combinator) -> Setter s t a b-setting = LF.setting+setting abst = LF.setting abst -- | 'resetting' promotes a \"semantic editor combinator\" to a form of grate that can only lift unary functions. -- To demote a grate to a semantic edit combinator, use @under l@ from "Lens.Family2".@@ -310,4 +310,4 @@ -- * @sec f . sec g === sec (f . g)@ resetting :: ((a -> b) -> s -> t) -- ^ sec (semantic editor combinator) -> Resetter s t a b-resetting = LF.resetting+resetting abst = LF.resetting abst