lenz 0.2.2.1 → 0.3.0.0
raw patch · 2 files changed
+9/−12 lines, 2 filesdep ~hs-functorsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: hs-functors
API changes (from Hackage documentation)
- Control.Lens: type Iso α β a b = Refractor Profunctor Functor α β a b
- Control.Lens: type Lens α β a b = Refractor ((~) (->)) Functor α β a b
- Control.Lens: type Traversal α β a b = Refractor ((~) (->)) Applicative α β a b
+ Control.Lens: type Traversal α β a b = forall f. Applicative f => (a -> f b) -> (α -> f β)
- Control.Lens: type Refractor c d α β a b = forall p f. (d f, c p) => p a (f b) -> p α (f β)
+ Control.Lens: type Iso α β a b = forall p f. (Profunctor p, Functor f) => p a (f b) -> p α (f β)
Files
- Control/Lens.hs +6/−9
- lenz.cabal +3/−3
Control/Lens.hs view
@@ -1,4 +1,4 @@-module Control.Lens (Lens, Refractor, Traversal, Iso,+module Control.Lens (Lens, Traversal, Iso, lens, iso, get, set, modify, mapping, fstL, sndL, swapL, unitL, bitL) where@@ -6,7 +6,6 @@ import Prelude hiding (id) import Control.Applicative-import Control.Arrow import Control.Category import Control.Category.Unicode import Data.Bits (Bits (..))@@ -15,13 +14,11 @@ 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 β)--type Lens α β a b = Refractor ((~) (→)) Functor α β a b+type Lens α β a b = ∀ f . Functor f => (a -> f b) -> (α -> f β) -type Traversal α β a b = Refractor ((~) (→)) Applicative α β a b+type Traversal α β a b = ∀ f . Applicative f => (a -> f b) -> (α -> f β) -type Iso α β a b = Refractor Profunctor Functor α β a b+type Iso α β a b = ∀ p f . (Profunctor p, Functor f) ⇒ p a (f b) -> p α (f β) lens :: (α → a) → (b → α → β) → Lens α β a b lens get set ret = liftA2 fmap (flip set) (ret ∘ get)@@ -42,13 +39,13 @@ 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 ∘ φ')+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 ∘ φ')+instance Profunctor (Xchg a b) where dimap f g (Xchg φ χ) = Xchg (φ ∘ f) (g ∘ χ) fstL :: Lens (a, c) (b, c) a b fstL = swapL ∘ sndL
lenz.cabal view
@@ -1,5 +1,5 @@ name: lenz-version: 0.2.2.1+version: 0.3.0.0 synopsis: Van Laarhoven lenses license: BSD3 author: M Farkas-Dyck@@ -16,7 +16,7 @@ exposed-modules: Control.Lens build-depends: base >= 4.8 && <5 , base-unicode-symbols >= 0.1 && <0.3- , hs-functors >=0.1 && <0.2+ , hs-functors >=0.1.1 && <0.2 , transformers >=0.2 && <0.6- extensions: UnicodeSyntax, RankNTypes, ConstraintKinds, GADTs, DeriveFunctor+ extensions: UnicodeSyntax, RankNTypes, ConstraintKinds, DeriveFunctor ghc-options: -Wall -Wno-name-shadowing