lens 5.1 → 5.1.1
raw patch · 20 files changed
+94/−45 lines, 20 filesdep ~mtldep ~transformersdep ~vectorPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: mtl, transformers, vector
API changes (from Hackage documentation)
+ Data.HashSet.Lens: hashMap :: Iso' (HashSet a) (HashMap a ())
Files
- .hlint.yaml +1/−1
- CHANGELOG.markdown +13/−0
- README.markdown +1/−1
- benchmarks/alongside.hs +1/−0
- examples/lens-examples.cabal +3/−3
- lens-properties/lens-properties.cabal +3/−3
- lens.cabal +6/−6
- src/Control/Lens/Each.hs +1/−0
- src/Control/Lens/Internal/Bazaar.hs +1/−0
- src/Control/Lens/Internal/Context.hs +1/−0
- src/Control/Lens/Internal/Indexed.hs +1/−0
- src/Control/Lens/Internal/Magma.hs +1/−0
- src/Control/Lens/Internal/PrismTH.hs +1/−1
- src/Control/Lens/Traversal.hs +2/−2
- src/Control/Lens/Type.hs +5/−0
- src/Control/Lens/Wrapped.hs +20/−14
- src/Control/Lens/Zoom.hs +23/−13
- src/Data/HashSet/Lens.hs +8/−1
- tests/T917.hs +1/−0
- tests/templates.hs +1/−0
.hlint.yaml view
@@ -1,4 +1,4 @@-- arguments: [--cpp-ansi, --cpp-include=include]+- arguments: [-XCPP, --cpp-ansi, --cpp-include=include] - ignore: {name: Reduce duplication} - ignore: {name: Redundant lambda}
CHANGELOG.markdown view
@@ -1,3 +1,16 @@+5.1.1 [2022.05.17]+------------------+* Add `Data.HashSet.Lens.hashMap`, an `Iso` between a `HashSet a` and a+ `HashMap a ()`.+* Allow building with `transformers-0.6.*` and `mtl-2.3.*`.++ Note that `lens` no longer defines `Zoom` instances for `ErrorT` or `ListT`+ when building with `mtl-2.3` or later. This is because `MonadState` is a+ superclass of `Zoom`, and the `MonadState` instances for `ErrorT` and `ListT`+ were removed in `mtl-2.3`. Be watchful of this if you build `lens` with+ `mtl-2.3` (or later) combined with an older version of `transformers`+ (pre-`0.6`) that defines `ErrorT` or `ListT`.+ 5.1 [2021.11.15] ---------------- * Allow building with GHC 9.2.
README.markdown view
@@ -236,6 +236,6 @@ Contributions and bug reports are welcome! -Please feel free to contact me through github or on the #haskell IRC channel on irc.freenode.net.+Please feel free to contact me through GitHub or on the [#haskell-lens](https://web.libera.chat/#haskell-lens) or [#haskell](https://web.libera.chat/#haskell) IRC channel on Libera Chat. -Edward Kmett
benchmarks/alongside.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} module Main (main) where
examples/lens-examples.cabal view
@@ -22,8 +22,8 @@ , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7- , GHC == 9.0.1- , GHC == 9.2.1+ , GHC == 9.0.2+ , GHC == 9.2.2 source-repository head type: git@@ -56,7 +56,7 @@ containers >= 0.4 && < 0.7, gloss >= 1.12 && < 1.14, lens,- mtl >= 2.0.1 && < 2.3,+ mtl >= 2.0.1 && < 2.4, random >= 1.0 && < 1.2, streams >= 3.3 && < 4 main-is: Pong.hs
lens-properties/lens-properties.cabal view
@@ -19,8 +19,8 @@ , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7- , GHC == 9.0.1- , GHC == 9.2.1+ , GHC == 9.0.2+ , GHC == 9.2.2 extra-source-files: .hlint.yaml@@ -35,7 +35,7 @@ base >= 4.9 && < 5, lens >= 4 && < 6, QuickCheck >= 2.4 && < 2.15,- transformers >= 0.2 && < 0.6+ transformers >= 0.2 && < 0.7 exposed-modules: Control.Lens.Properties
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses, Generics-version: 5.1+version: 5.1.1 license: BSD2 cabal-version: 1.18 license-file: LICENSE@@ -18,8 +18,8 @@ , GHC == 8.6.5 , GHC == 8.8.4 , GHC == 8.10.7- , GHC == 9.0.1- , GHC == 9.2.1+ , GHC == 9.0.2+ , GHC == 9.2.2 synopsis: Lenses, Folds and Traversals description: This package comes \"Batteries Included\" with many useful lenses for the types@@ -189,7 +189,7 @@ indexed-traversable >= 0.1 && < 0.2, indexed-traversable-instances >= 0.1 && < 0.2, kan-extensions >= 5 && < 6,- mtl >= 2.2.1 && < 2.3,+ mtl >= 2.2.1 && < 2.4, parallel >= 3.2.1.0 && < 3.3, profunctors >= 5.5.2 && < 6, reflection >= 2.1 && < 3,@@ -197,10 +197,10 @@ strict >= 0.4 && < 0.5, tagged >= 0.8.6 && < 1, template-haskell >= 2.11.1.0 && < 2.19,- text >= 1.2.3.0 && < 1.3,+ text >= 1.2.3.0 && < 2.1, th-abstraction >= 0.4.1 && < 0.5, these >= 1.1.1.1 && < 1.2,- transformers >= 0.5.0.0 && < 0.6,+ transformers >= 0.5.0.0 && < 0.7, transformers-compat >= 0.5.0.4 && < 1, unordered-containers >= 0.2.10 && < 0.3, vector >= 0.12.1.2 && < 0.13
src/Control/Lens/Each.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE DefaultSignatures #-}
src/Control/Lens/Internal/Bazaar.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE RoleAnnotations #-}
src/Control/Lens/Internal/Context.hs view
@@ -1,5 +1,6 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE FunctionalDependencies #-}
src/Control/Lens/Internal/Indexed.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-}
src/Control/Lens/Internal/Magma.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE RoleAnnotations #-} -----------------------------------------------------------------------------
src/Control/Lens/Internal/PrismTH.hs view
@@ -513,7 +513,7 @@ -- | Compute a prism's name with a special case for when the type -- constructor matches one of the value constructors. ----- The overlapping flag wil be 'True' in the event that:+-- The overlapping flag will be 'True' in the event that: -- -- 1. We are generating the name of a classy prism for a -- data type, and
src/Control/Lens/Traversal.hs view
@@ -302,8 +302,8 @@ -- Note that the 'traversal' function actually just returns the same function you pass to -- it. The function it accepts is in fact a valid traversal all on its own! The use of -- 'traversal' does nothing except verify that the function it is passed matches the signature--- of a valid traversal. One could remove the @traversal@ cominator from either of the last--- two examples and use the definiton of @go@ directly with no change in behaviour.+-- of a valid traversal. One could remove the @traversal@ combinator from either of the last+-- two examples and use the definition of @go@ directly with no change in behaviour. -- -- This function exists for consistency with the 'lens', 'prism' and 'iso' constructors -- as well as to serve as a touchpoint for beginners who wish to construct their own
src/Control/Lens/Type.hs view
@@ -201,6 +201,11 @@ -- @ type Traversal' s a = Traversal s s a a +-- | A 'Traversal' which targets at least one element.+--+-- Note that since 'Apply' is not a superclass of 'Applicative', a 'Traversal1'+-- cannot always be used in place of a 'Traversal'. In such circumstances+-- 'Control.Lens.Traversal.cloneTraversal' will convert a 'Traversal1' into a 'Traversal'. type Traversal1 s t a b = forall f. Apply f => (a -> f b) -> s -> f t type Traversal1' s a = Traversal1 s s a a
src/Control/Lens/Wrapped.hs view
@@ -15,7 +15,9 @@ {-# LANGUAGE Trustworthy #-} #endif +#if !(MIN_VERSION_base(4,16,0)) || !MIN_VERSION_transformers(0,6,0) {-# OPTIONS_GHC -Wno-warnings-deprecations #-}+#endif #include "lens-common.h" @@ -88,12 +90,10 @@ import Control.Lens.Review import Control.Monad.Catch.Pure import Control.Monad.Trans.Cont-import Control.Monad.Trans.Error import Control.Monad.Trans.Except import Control.Monad.Trans.Free import Control.Monad.Trans.Identity import Control.Monad.Trans.Iter-import Control.Monad.Trans.List import Control.Monad.Trans.Maybe import Control.Monad.Trans.Reader import qualified Control.Monad.Trans.RWS.Lazy as Lazy@@ -102,6 +102,10 @@ import qualified Control.Monad.Trans.State.Strict as Strict import qualified Control.Monad.Trans.Writer.Lazy as Lazy import qualified Control.Monad.Trans.Writer.Strict as Strict+#if !MIN_VERSION_transformers(0,6,0)+import Control.Monad.Trans.Error+import Control.Monad.Trans.List+#endif import Data.Bifunctor.Biff import Data.Bifunctor.Clown import Data.Bifunctor.Fix@@ -372,12 +376,6 @@ type Unwrapped (ContT r m a) = (a -> m r) -> m r _Wrapped' = iso runContT ContT -instance (t ~ ErrorT e' m' a') => Rewrapped (ErrorT e m a) t-instance Wrapped (ErrorT e m a) where- type Unwrapped (ErrorT e m a) = m (Either e a)- _Wrapped' = iso runErrorT ErrorT- {-# INLINE _Wrapped' #-}- instance (t ~ ExceptT e' m' a') => Rewrapped (ExceptT e m a) t instance Wrapped (ExceptT e m a) where type Unwrapped (ExceptT e m a) = m (Either e a)@@ -396,12 +394,6 @@ _Wrapped' = iso runIdentityT IdentityT {-# INLINE _Wrapped' #-} -instance (t ~ ListT n b) => Rewrapped (ListT m a) t-instance Wrapped (ListT m a) where- type Unwrapped (ListT m a) = m [a]- _Wrapped' = iso runListT ListT- {-# INLINE _Wrapped' #-}- instance (t ~ MaybeT n b) => Rewrapped (MaybeT m a) t instance Wrapped (MaybeT m a) where type Unwrapped (MaybeT m a) = m (Maybe a)@@ -455,6 +447,20 @@ type Unwrapped (Strict.WriterT w m a) = m (a, w) _Wrapped' = iso Strict.runWriterT Strict.WriterT {-# INLINE _Wrapped' #-}++#if !MIN_VERSION_transformers(0,6,0)+instance (t ~ ErrorT e' m' a') => Rewrapped (ErrorT e m a) t+instance Wrapped (ErrorT e m a) where+ type Unwrapped (ErrorT e m a) = m (Either e a)+ _Wrapped' = iso runErrorT ErrorT+ {-# INLINE _Wrapped' #-}++instance (t ~ ListT n b) => Rewrapped (ListT m a) t+instance Wrapped (ListT m a) where+ type Unwrapped (ListT m a) = m [a]+ _Wrapped' = iso runListT ListT+ {-# INLINE _Wrapped' #-}+#endif -- * bifunctors
src/Control/Lens/Zoom.hs view
@@ -1,13 +1,17 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE RankNTypes #-}-{-# OPTIONS_GHC -Wno-warnings-deprecations #-} {-# LANGUAGE Trustworthy #-} +#if !MIN_VERSION_transformers(0,6,0)+{-# OPTIONS_GHC -Wno-warnings-deprecations #-}+#endif+ #include "lens-common.h" -------------------------------------------------------------------------------@@ -42,12 +46,14 @@ import Control.Monad.Trans.Writer.Strict as Strict import Control.Monad.Trans.RWS.Lazy as Lazy import Control.Monad.Trans.RWS.Strict as Strict-import Control.Monad.Trans.Error import Control.Monad.Trans.Except-import Control.Monad.Trans.List import Control.Monad.Trans.Identity import Control.Monad.Trans.Maybe import Control.Monad.Trans.Free+#if !MIN_VERSION_transformers(0,6,0)+import Control.Monad.Trans.Error+import Control.Monad.Trans.List+#endif import Data.Kind -- $setup@@ -78,11 +84,13 @@ type instance Zoomed (Lazy.RWST r w s z) = FocusingWith w z type instance Zoomed (Strict.WriterT w m) = FocusingPlus w (Zoomed m) type instance Zoomed (Lazy.WriterT w m) = FocusingPlus w (Zoomed m)-type instance Zoomed (ListT m) = FocusingOn [] (Zoomed m) type instance Zoomed (MaybeT m) = FocusingMay (Zoomed m)-type instance Zoomed (ErrorT e m) = FocusingErr e (Zoomed m) type instance Zoomed (ExceptT e m) = FocusingErr e (Zoomed m) type instance Zoomed (FreeT f m) = FocusingFree f m (Zoomed m)+#if !MIN_VERSION_transformers(0,6,0)+type instance Zoomed (ErrorT e m) = FocusingErr e (Zoomed m)+type instance Zoomed (ListT m) = FocusingOn [] (Zoomed m)+#endif ------------------------------------------------------------------------------ -- Magnified@@ -174,24 +182,26 @@ zoom l = Lazy.WriterT . zoom (\afb -> unfocusingPlus #. l (FocusingPlus #. afb)) . Lazy.runWriterT {-# INLINE zoom #-} -instance Zoom m n s t => Zoom (ListT m) (ListT n) s t where- zoom l = ListT . zoom (\afb -> unfocusingOn . l (FocusingOn . afb)) . runListT- {-# INLINE zoom #-}- instance Zoom m n s t => Zoom (MaybeT m) (MaybeT n) s t where zoom l = MaybeT . liftM getMay . zoom (\afb -> unfocusingMay #. l (FocusingMay #. afb)) . liftM May . runMaybeT {-# INLINE zoom #-} -instance (Error e, Zoom m n s t) => Zoom (ErrorT e m) (ErrorT e n) s t where- zoom l = ErrorT . liftM getErr . zoom (\afb -> unfocusingErr #. l (FocusingErr #. afb)) . liftM Err . runErrorT- {-# INLINE zoom #-}- instance Zoom m n s t => Zoom (ExceptT e m) (ExceptT e n) s t where zoom l = ExceptT . liftM getErr . zoom (\afb -> unfocusingErr #. l (FocusingErr #. afb)) . liftM Err . runExceptT {-# INLINE zoom #-} instance (Functor f, Zoom m n s t) => Zoom (FreeT f m) (FreeT f n) s t where zoom l = FreeT . liftM (fmap (zoom l) . getFreed) . zoom (\afb -> unfocusingFree #. l (FocusingFree #. afb)) . liftM Freed . runFreeT++#if !MIN_VERSION_transformers(0,6,0) && !MIN_VERSION_mtl(2,3,0)+instance (Error e, Zoom m n s t) => Zoom (ErrorT e m) (ErrorT e n) s t where+ zoom l = ErrorT . liftM getErr . zoom (\afb -> unfocusingErr #. l (FocusingErr #. afb)) . liftM Err . runErrorT+ {-# INLINE zoom #-}++instance Zoom m n s t => Zoom (ListT m) (ListT n) s t where+ zoom l = ListT . zoom (\afb -> unfocusingOn . l (FocusingOn . afb)) . runListT+ {-# INLINE zoom #-}+#endif ------------------------------------------------------------------------------ -- Magnify
src/Data/HashSet/Lens.hs view
@@ -12,13 +12,16 @@ module Data.HashSet.Lens ( setmapped , setOf+ , hashMap ) where import Control.Lens.Getter (Getting, views)+import Control.Lens.Iso (iso) import Control.Lens.Setter (setting) import Control.Lens.Type import qualified Data.HashSet as HashSet-import Data.HashSet (HashSet)+import Data.HashSet (HashSet, fromMap, toMap)+import Data.HashMap.Lazy (HashMap) import Data.Hashable -- $setup@@ -46,3 +49,7 @@ setOf :: Hashable a => Getting (HashSet a) s a -> s -> HashSet a setOf l = views l HashSet.singleton {-# INLINE setOf #-}++-- | An `Iso` between a `HashSet` and a `HashMap` with unit values. \(\mathcal{O}(1)\).+hashMap :: Iso' (HashSet a) (HashMap a ())+hashMap = iso toMap fromMap
tests/T917.hs view
@@ -5,6 +5,7 @@ {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TemplateHaskell #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} #if __GLASGOW_HASKELL__ < 806 {-# LANGUAGE TypeInType #-}
tests/templates.hs view
@@ -4,6 +4,7 @@ {-# LANGUAGE FunctionalDependencies #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE TypeOperators #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE UndecidableInstances #-}