lens 3.10 → 3.10.0.1
raw patch · 16 files changed
+89/−32 lines, 16 filesdep ~text
Dependency ranges changed: text
Files
- CHANGELOG.markdown +4/−0
- lens.cabal +2/−2
- src/Control/Exception/Lens.hs +2/−0
- src/Control/Lens.hs +2/−0
- src/Control/Lens/Equality.hs +3/−0
- src/Control/Lens/Fold.hs +2/−0
- src/Control/Lens/Internal.hs +3/−0
- src/Control/Lens/Internal/Zipper.hs +2/−0
- src/Control/Lens/Iso.hs +2/−0
- src/Control/Lens/Lens.hs +2/−0
- src/Control/Lens/Operators.hs +3/−0
- src/Control/Lens/Plated.hs +2/−0
- src/Control/Lens/Setter.hs +2/−0
- src/Control/Lens/TH.hs +2/−0
- src/Control/Lens/Traversal.hs +53/−30
- src/Data/Data/Lens.hs +3/−0
CHANGELOG.markdown view
@@ -1,3 +1,7 @@+3.10.0.1 [maintenance release]+--------+* Compatibility with `text` 1.0+ 3.10 ---- * Switched to `bifunctors`, `comonad`, `profunctors`, and `semigroupoids` 4.0.
lens.cabal view
@@ -1,6 +1,6 @@ name: lens category: Data, Lenses-version: 3.10+version: 3.10.0.1 license: BSD3 cabal-version: >= 1.8 license-file: LICENSE@@ -186,7 +186,7 @@ split >= 0.2 && < 0.3, tagged >= 0.4.4 && < 1, template-haskell >= 2.4 && < 2.10,- text >= 0.11 && < 0.12,+ text >= 0.11 && < 1.2, transformers >= 0.2 && < 0.4, transformers-compat >= 0.1 && < 1, unordered-containers >= 0.2 && < 0.3,
src/Control/Exception/Lens.hs view
@@ -112,7 +112,9 @@ , Maybe(..), Either(..), Functor(..), String, IO ) +#ifdef HLINT {-# ANN module "HLint: ignore Use Control.Exception.catch" #-}+#endif -- $setup -- >>> :set -XNoOverloadedStrings
src/Control/Lens.hs view
@@ -99,4 +99,6 @@ import Control.Lens.Zipper import Control.Lens.Zoom +#ifdef HLINT {-# ANN module "HLint: ignore Use import/export shortcut" #-}+#endif
src/Control/Lens/Equality.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE Rank2Types #-} {-# LANGUAGE TypeFamilies #-}@@ -28,8 +29,10 @@ import Control.Lens.Internal.Setter import Control.Lens.Type +#ifdef HLINT {-# ANN module "HLint: ignore Use id" #-} {-# ANN module "HLint: ignore Eta reduce" #-}+#endif -- $setup -- >>> import Control.Lens
src/Control/Lens/Fold.hs view
@@ -163,9 +163,11 @@ -- >>> let g :: Expr -> Expr; g = Debug.SimpleReflect.Vars.g -- >>> let timingOut :: NFData a => a -> IO a; timingOut = fmap (fromMaybe (error "timeout")) . timeout (5*10^6) . evaluate . force +#ifdef HLINT {-# ANN module "HLint: ignore Eta reduce" #-} {-# ANN module "HLint: ignore Use camelCase" #-} {-# ANN module "HLint: ignore Use curry" #-}+#endif infixl 8 ^.., ^?, ^?!, ^@.., ^@?, ^@?!
src/Control/Lens/Internal.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Internal@@ -43,4 +44,6 @@ import Control.Lens.Internal.Setter import Control.Lens.Internal.Zoom +#ifdef HLINT {-# ANN module "HLint: ignore Use import/export shortcut" #-}+#endif
src/Control/Lens/Internal/Zipper.hs view
@@ -53,7 +53,9 @@ -- >>> import Control.Lens -- >>> import Data.Char +#ifdef HLINT {-# ANN module "HLint: ignore Use foldl" #-}+#endif ------------------------------------------------------------------------------ -- * Jacket
src/Control/Lens/Iso.hs view
@@ -82,7 +82,9 @@ import Data.Profunctor import Data.Profunctor.Unsafe +#ifdef HLINT {-# ANN module "HLint: ignore Use on" #-}+#endif -- $setup -- >>> :set -XNoOverloadedStrings
src/Control/Lens/Lens.hs view
@@ -126,7 +126,9 @@ import Data.Profunctor.Unsafe import Data.Void +#ifdef HLINT {-# ANN module "HLint: ignore Use ***" #-}+#endif -- $setup -- >>> :set -XNoOverloadedStrings
src/Control/Lens/Operators.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} ----------------------------------------------------------------------------- -- | -- Module : Control.Lens.Operators@@ -108,4 +109,6 @@ import Control.Lens.Setter import Control.Lens.Zipper +#ifdef HLINT {-# ANN module "HLint: ignore Use import/export shortcut" #-}+#endif
src/Control/Lens/Plated.hs view
@@ -95,7 +95,9 @@ import Data.Monoid import Data.Tree +#ifdef HLINT {-# ANN module "HLint: ignore Reduce duplication" #-}+#endif -- | A 'Plated' type is one where we know how to extract its immediate self-similar children. --
src/Control/Lens/Setter.hs view
@@ -87,7 +87,9 @@ import Data.Profunctor.Rep import Data.Profunctor.Unsafe +#ifdef HLINT {-# ANN module "HLint: ignore Avoid lambda" #-}+#endif -- $setup -- >>> import Control.Lens
src/Control/Lens/TH.hs view
@@ -87,7 +87,9 @@ import Language.Haskell.TH.Syntax import Language.Haskell.TH.Lens +#ifdef HLINT {-# ANN module "HLint: ignore Use foldl" #-}+#endif -- | Flags for 'Lens' construction data LensFlag
src/Control/Lens/Traversal.hs view
@@ -115,7 +115,6 @@ import Control.Applicative.Backwards import Control.Category import Control.Comonad-import Control.Monad import Control.Lens.Combinators import Control.Lens.Fold import Control.Lens.Getter (coerced)@@ -123,17 +122,20 @@ import Control.Lens.Internal.Context import Control.Lens.Internal.Indexed import Control.Lens.Type+import Control.Monad import Control.Monad.Trans.State.Lazy import Data.Functor.Compose import Data.Int import Data.IntMap as IntMap import Data.Map as Map import Data.Monoid-import Data.Traversable-import Data.Tuple (swap) import Data.Profunctor import Data.Profunctor.Rep import Data.Profunctor.Unsafe+import Data.Tagged+import Data.Traversable+import Data.Tuple (swap)+import GHC.Magic (inline) import Prelude hiding ((.),id) -- $setup@@ -470,9 +472,9 @@ -- | An indexed version of 'partsOf' that receives the entire list of indices as its index. ipartsOf :: forall i p f s t a. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a a -> Over p f s t [a] [a]-ipartsOf l f s = outs b <$> indexed f (is :: [i]) as where- (is,as) = unzip (pins b)- b = l sell s+ipartsOf l = conjoined+ (\f s -> let b = inline l sell s in outs b <$> f (wins b))+ (\f s -> let b = inline l sell s; (is, as) = unzip (pins b) in outs b <$> indexed f (is :: [i]) as) {-# INLINE ipartsOf #-} -- | A type-restricted version of 'partsOf' that can only be used with a 'Traversal'.@@ -482,9 +484,9 @@ -- | A type-restricted version of 'ipartsOf' that can only be used with an 'IndexedTraversal'. ipartsOf' :: forall i p f s t a. (Indexable [i] p, Functor f) => Over (Indexed i) (Bazaar' (Indexed i) a) s t a a -> Over p f s t [a] [a]-ipartsOf' l f s = outs b <$> indexed f (is :: [i]) as where- (is,as) = unzip (pins b)- b = l sell s+ipartsOf' l = conjoined+ (\f s -> let b = inline l sell s in outs b <$> f (wins b))+ (\f s -> let b = inline l sell s; (is, as) = unzip (pins b) in outs b <$> indexed f (is :: [i]) as) {-# INLINE ipartsOf' #-} -- | 'unsafePartsOf' turns a 'Traversal' into a 'Data.Data.Lens.uniplate' (or 'Data.Data.Lens.biplate') family.@@ -513,9 +515,9 @@ -- | An indexed version of 'unsafePartsOf' that receives the entire list of indices as its index. iunsafePartsOf :: forall i p f s t a b. (Indexable [i] p, Functor f) => Traversing (Indexed i) f s t a b -> Over p f s t [a] [b]-iunsafePartsOf l f s = unsafeOuts b <$> indexed f (is :: [i]) as where- (is,as) = unzip (pins b)- b = l sell s+iunsafePartsOf l = conjoined+ (\f s -> let b = inline l sell s in unsafeOuts b <$> f (wins b))+ (\f s -> let b = inline l sell s; (is,as) = unzip (pins b) in unsafeOuts b <$> indexed f (is :: [i]) as) {-# INLINE iunsafePartsOf #-} unsafePartsOf' :: ATraversal s t a b -> Lens s t [a] [b]@@ -523,9 +525,9 @@ {-# INLINE unsafePartsOf' #-} iunsafePartsOf' :: forall i s t a b. Over (Indexed i) (Bazaar (Indexed i) a b) s t a b -> IndexedLens [i] s t [a] [b]-iunsafePartsOf' l f s = unsafeOuts b <$> indexed f (is :: [i]) as where- (is,as) = unzip (pins b)- b = l sell s+iunsafePartsOf' l = conjoined+ (\f s -> let b = inline l sell s in unsafeOuts b <$> f (wins b))+ (\f s -> let b = inline l sell s; (is, as) = unzip (pins b) in unsafeOuts b <$> indexed f (is :: [i]) as) {-# INLINE iunsafePartsOf' #-} -- | The one-level version of 'Control.Lens.Plated.contextsOf'. This extracts a list of the immediate children according to a given 'Traversal' as editable contexts.@@ -544,11 +546,19 @@ -- 'holesOf' :: 'IndexedLens'' i s a -> s -> ['Pretext'' ('Indexed' i) a s] -- 'holesOf' :: 'IndexedTraversal'' i s a -> s -> ['Pretext'' ('Indexed' i) a s] -- @-holesOf :: Conjoined p => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]-holesOf l s = f (pins b) (unsafeOuts b) where- b = l sell s- f [] _ = []- f (wx:xs) g = Pretext (\wxfy -> g . (:Prelude.map extract xs) <$> corep wxfy wx) : f xs (g . (extract wx:))+holesOf :: forall p s t a. Conjoined p => Over p (Bazaar p a a) s t a a -> s -> [Pretext p a a t]+holesOf l s = unTagged+ ( conjoined+ (Tagged $ let+ f [] _ = []+ f (x:xs) g = Pretext (\xfy -> g . (:xs) <$> xfy x) : f xs (g . (x:))+ in f (ins b) (unsafeOuts b))+ (Tagged $ let+ f [] _ = []+ f (wx:xs) g = Pretext (\wxfy -> g . (:Prelude.map extract xs) <$> corep wxfy wx) : f xs (g . (extract wx:))+ in f (pins b) (unsafeOuts b))+ :: Tagged (p a b) [Pretext p a a t]+ ) where b = l sell s {-# INLINE holesOf #-} -- | This converts a 'Traversal' that you \"know\" will target one or more elements to a 'Lens'. It can@@ -569,10 +579,13 @@ singular :: (Conjoined p, Functor f) => Over p (BazaarT p f a a) s t a a -> Over p f s t a a-singular l pafb s = case pins b of- (w:ws) -> unsafeOuts b . (:Prelude.map extract ws) <$> corep pafb w- [] -> unsafeOuts b . return <$> corep pafb (error "singular: empty traversal")- where b = l sell s+singular l = conjoined+ (\afb s -> let b = l sell s in case ins b of+ (w:ws) -> unsafeOuts b . (:ws) <$> afb w+ [] -> unsafeOuts b . return <$> afb (error "singular: empty traversal"))+ (\pafb s -> let b = l sell s in case pins b of+ (w:ws) -> unsafeOuts b . (:Prelude.map extract ws) <$> corep pafb w+ [] -> unsafeOuts b . return <$> corep pafb (error "singular: empty traversal")) {-# INLINE singular #-} -- | This converts a 'Traversal' that you \"know\" will target only one element to a 'Lens'. It can also be@@ -592,11 +605,15 @@ unsafeSingular :: (Conjoined p, Functor f) => Over p (BazaarT p f a b) s t a b -> Over p f s t a b-unsafeSingular l pafb s = case pins b of- [w] -> unsafeOuts b . return <$> corep pafb w- [] -> error "unsafeSingular: empty traversal"- _ -> error "unsafeSingular: traversing multiple results"- where b = l sell s+unsafeSingular l = conjoined+ (\afb s -> let b = inline l sell s in case ins b of+ [w] -> unsafeOuts b . return <$> afb w+ [] -> error "unsafeSingular: empty traversal"+ _ -> error "unsafeSingular: traversing multiple results")+ (\pafb s -> let b = inline l sell s in case pins b of+ [w] -> unsafeOuts b . return <$> corep pafb w+ [] -> error "unsafeSingular: empty traversal"+ _ -> error "unsafeSingular: traversing multiple results") {-# INLINE unsafeSingular #-} ------------------------------------------------------------------------------@@ -607,6 +624,10 @@ ins = toListOf (coerced bazaar) {-# INLINE ins #-} +wins :: (Bizarre p w, Corepresentable p, Comonad (Corep p)) => w a b t -> [a]+wins = getConst #. bazaar (cotabulate $ \ra -> Const [extract ra])+{-# INLINE wins #-}+ pins :: (Bizarre p w, Corepresentable p) => w a b t -> [Corep p a] pins = getConst #. bazaar (cotabulate $ \ra -> Const [ra]) {-# INLINE pins #-}@@ -716,7 +737,9 @@ => Int -> Over p (BazaarT p f a a) s t a a -> Over p f s t a a-taking n l pafb s = outs b <$> traverse (corep pafb) (take n $ pins b) where b = l sell s+taking n l = conjoined+ (\ afb s -> let b = inline l sell s in outs b <$> traverse afb (take n $ ins b))+ (\ pafb s -> let b = inline l sell s in outs b <$> traverse (corep pafb) (take n $ pins b)) {-# INLINE taking #-} -- | Visit all but the first /n/ targets of a 'Traversal', 'Fold', 'Getter' or 'Lens'.
src/Data/Data/Lens.hs view
@@ -10,6 +10,7 @@ #ifdef TRUSTWORTHY {-# LANGUAGE Trustworthy #-} #endif+{-# OPTIONS_GHC -fno-full-laziness #-} ----------------------------------------------------------------------------- -- | -- Module : Data.Data.Lens@@ -65,9 +66,11 @@ import GHC.Exts (realWorld#) #endif +#ifdef HLINT {-# ANN module "HLint: ignore Eta reduce" #-} {-# ANN module "HLint: ignore Use foldl" #-} {-# ANN module "HLint: ignore Reduce duplication" #-}+#endif -- $setup -- >>> :set -XNoOverloadedStrings