packages feed

lenz 0.2.0.0 → 0.2.1.0

raw patch · 3 files changed

+29/−15 lines, 3 filesdep +profunctorsPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

Dependencies added: profunctors

API changes (from Hackage documentation)

+ Control.Lens: bitL :: Bits a => Int -> Lens a a Bool Bool
+ Control.Lens: instance Data.Profunctor.Unsafe.Profunctor (Control.Lens.Xchg a b)
+ Control.Lens: instance GHC.Base.Functor (Control.Lens.Xchg a b α)
+ Control.Lens: mapping :: (Functor f, Functor g) => AnIso α β a b -> Iso (f α) (g β) (f a) (g b)
- Control.Lens: iso :: (α -> a) -> (b -> β) -> Lens α β a b
+ Control.Lens: iso :: (α -> a) -> (b -> β) -> Iso α β a b
- Control.Lens: swapL :: Lens (a, b) (c, d) (b, a) (d, c)
+ Control.Lens: swapL :: Iso (a, b) (c, d) (b, a) (d, c)

Files

Control/Lens.hs view
@@ -1,7 +1,7 @@ module Control.Lens (Lens, Refractor, Traversal,                      lens, iso,-                     get, set, modify,-                     fstL, sndL, swapL, unitL) where+                     get, set, modify, mapping,+                     fstL, sndL, swapL, unitL, bitL) where  import Prelude hiding (id) @@ -12,6 +12,7 @@ import Data.Bits (Bits (..)) import Data.Bool (bool) import Data.Functor.Identity+import Data.Profunctor import Data.Tuple (swap)  type Refractor c d α β a b = ∀ p f . (d f, c p) ⇒ p a (f b) → p α (f β)@@ -20,11 +21,13 @@  type Traversal α β a b = Refractor ((~) (→)) Applicative α β a b +type Iso α β a b = Refractor Profunctor Functor α β a b+ lens :: (α → a) → (b → α → β) → Lens α β a b lens get set ret = liftA2 fmap (flip set) (ret ∘ get) -iso :: (α → a) → (b → β) → Lens α β a b-iso f g = (fmap g ∘) ∘ (∘ f)+iso :: (α → a) → (b → β) → Iso α β a b+iso f g = dimap f (fmap g)  get :: ((a → Const a b) → α → Const a β) → α → a get l = getConst ∘ l Const@@ -35,13 +38,25 @@ modify :: ((a → Identity b) → α → Identity β) → (a → b) → α → β modify l f = runIdentity ∘ l (Identity ∘ f) +mapping :: (Functor f, Functor g) => AnIso α β a b -> Iso (f α) (g β) (f a) (g b)+mapping = (`withIso` \ f g -> iso (fmap f) (fmap g))++withIso :: AnIso α β a b -> ((α -> a) -> (b -> β) -> c) -> c+withIso x = case x (Xchg id Identity) of Xchg φ φ' -> \ f -> f φ (runIdentity ∘ φ')++type AnIso α β a b = Xchg a b a (Identity b) -> Xchg a b α (Identity β)++data Xchg a b α β = Xchg (α -> a) (b -> β) deriving (Functor)++instance Profunctor (Xchg a b) where dimap f g (Xchg φ φ') = Xchg (φ ∘ f) (g ∘ φ')+ fstL :: Lens (a, c) (b, c) a b fstL = swapL ∘ sndL  sndL :: Lens (a, b) (a, c) b c sndL f = id *** f >>> uncurry (fmap ∘ (,)) -swapL :: Lens (a, b) (c, d) (b, a) (d, c)+swapL :: Iso (a, b) (c, d) (b, a) (d, c) swapL = iso swap swap  unitL :: Lens α α () ()
− LICENSE
@@ -1,5 +0,0 @@-© Unix year 44 (Strake = M Farkas-Dyck)--Leave to use, copy, modify, and distribute this work for any purpose is hereby granted if the above copyright notice and this license are included.--THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
lenz.cabal view
@@ -1,9 +1,9 @@ name:           lenz-version:        0.2.0.0+version:        0.2.1.0 synopsis:       Van Laarhoven lenses-license:        OtherLicense-license-file:   LICENSE+license:        BSD3 author:	        M Farkas-Dyck+copyright:      © Unix year 47 M Farkas-Dyck maintainer:     strake888@gmail.com category:       Data, Lenses build-type:     Simple@@ -14,5 +14,9 @@  library   exposed-modules:      Control.Lens-  build-depends:        base >= 4.8 && <5, base-unicode-symbols >= 0.1 && <0.3, transformers >=0.2 && <0.6-  extensions:           UnicodeSyntax, RankNTypes, ConstraintKinds, GADTs+  build-depends:        base >= 4.8 && <5+                      , base-unicode-symbols >= 0.1 && <0.3+                      , profunctors >=5.2.1 && <5.3+                      , transformers >=0.2 && <0.6+  extensions:           UnicodeSyntax, RankNTypes, ConstraintKinds, GADTs, DeriveFunctor+  ghc-options:          -Wall -Wno-name-shadowing