data-diverse-lens 4.2.0.1 → 4.3.0.0
raw patch · 6 files changed
+98/−140 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Data.Diverse.Lens.Many: piece :: Had a s => Lens s (Replaced a b s) a b
- Data.Diverse.Lens.Many: piece' :: Has a s => Lens' s a
- Data.Diverse.Lens.Many: pieceL :: HadL l a s => Lens s (ReplacedL l a b s) a b
- Data.Diverse.Lens.Many: pieceL' :: HasL l a s => Lens' s a
- Data.Diverse.Lens.Many: pieceN :: HadN n a s => Lens s (ReplacedN n a b s) a b
- Data.Diverse.Lens.Many: pieceN' :: HasN n a s => Lens' s a
- Data.Diverse.Lens.Many: pieceTag :: forall l a b s. Had (Tagged l a) s => Lens s (Replaced (Tagged l a) (Tagged l b) s) a b
- Data.Diverse.Lens.Many: pieceTag' :: forall l a s. Has (Tagged l a) s => Lens' s a
- Data.Diverse.Profunctor.Many: pieced :: forall w a b s t. (Profunctor w, Strong w, Pieced a b s t) => w a b -> w s t
- Data.Diverse.Profunctor.Many: piecedK :: forall m a b s t. (Monad m, Pieced a b s t) => (a -> m b) -> (s -> m t)
- Data.Diverse.Profunctor.Many: type Pieced a b s t = (Had a s, t ~ Replaced a b s)
+ Data.Diverse.Lens.Many: hadL :: HadL l a s => Lens s (ReplacedL l a b s) a b
+ Data.Diverse.Lens.Many: hadLens :: Had a s => Lens s (Replaced a b s) a b
+ Data.Diverse.Lens.Many: hadN :: HadN n a s => Lens s (ReplacedN n a b s) a b
+ Data.Diverse.Lens.Many: hadTag :: forall l a b s. Had (Tagged l a) s => Lens s (Replaced (Tagged l a) (Tagged l b) s) a b
+ Data.Diverse.Lens.Many: hasL :: HasL l a s => Lens' s a
+ Data.Diverse.Lens.Many: hasN :: HasN n a s => Lens' s a
+ Data.Diverse.Lens.Many: hasTag :: forall l a s. Has (Tagged l a) s => Lens' s a
+ Data.Diverse.Profunctor.Many: have :: forall w a b s t. (Profunctor w, Strong w, Have a b s t) => w a b -> w s t
+ Data.Diverse.Profunctor.Many: haveK :: forall m a b s t. (Monad m, Have a b s t) => (a -> m b) -> (s -> m t)
+ Data.Diverse.Profunctor.Many: type Have a b s t = (Had a s, t ~ Replaced a b s)
- Data.Diverse.Lens.Many: modifier :: Has a t => (a -> a) -> t -> t
+ Data.Diverse.Lens.Many: modifier :: Has a t => a -> a -> t -> t
Files
- README.md +4/−0
- data-diverse-lens.cabal +2/−2
- src/Data/Diverse/Lens/Many.hs +42/−43
- src/Data/Diverse/Profunctor/Many.hs +12/−12
- src/Data/Diverse/Profunctor/Which.hs +0/−45
- test/Data/Diverse/Lens/ManySpec.hs +38/−38
README.md view
@@ -7,6 +7,10 @@ # Changelog +* 4.3.0.0+ - Replaced `piece'` with `hasLens`, `piece` with `hadLens`+ - Replaced `pieceX'` with `hasX`, `pieceX` `hadX`+ * 4.2.0.1 - Missed removing Semigroup constraint from `chooseWith`
data-diverse-lens.cabal view
@@ -1,5 +1,5 @@ name: data-diverse-lens-version: 4.2.0.1+version: 4.3.0.0 synopsis: Isos & Lens for Data.Diverse.Many and Prisms for Data.Diverse.Which description: Isos & Lens for Data.Diverse.Many and Prisms for Data.Diverse.Which Refer to [ManySpec.hs](https://github.com/louispan/data-diverse-lens/blob/master/test/Data/Diverse/Lens/ManySpec.hs) and [WhichSpec.hs](https://github.com/louispan/data-diverse-lens/blob/master/test/Data/Diverse/Lens/WhichSpec.hs) for example usages.@@ -29,7 +29,7 @@ , profunctors >= 5.2 , lens >= 4 , data-has >= 0.3- ghc-options: -Wall+ ghc-options: -Wall -Wredundant-constraints default-language: Haskell2010 test-suite data-diverse-lens-test
src/Data/Diverse/Lens/Many.hs view
@@ -24,9 +24,8 @@ -- * Single field -- ** Lens for a single field , Has(..)- , piece'- , pieceTag- , pieceTag'+ , hasTag+ , hadTag , Had(..) , HasL(..) , HadL(..)@@ -69,97 +68,97 @@ ----------------------------------------------------------------------- --- | Convient name for 'hasLens' to be consistent with 'Had' typeclass.------ @--- let x = (5 :: Int) './' False './' \'X' './' Just \'O' './' 'nil'--- x '^.' 'piece'' \@Int \`shouldBe` 5--- (x '&' 'piece'' \@Int .~ 6) \`shouldBe` (6 :: Int) './' False './' \'X' './' Just \'O' './' 'nil'--- @-piece' :: Has a s => Lens' s a-piece' = hasLens+-- -- | Convient name for 'hasLens' to be consistent with 'Had' typeclass.+-- --+-- -- @+-- -- let x = (5 :: Int) './' False './' \'X' './' Just \'O' './' 'nil'+-- -- x '^.' 'has'' \@Int \`shouldBe` 5+-- -- (x '&' 'has'' \@Int .~ 6) \`shouldBe` (6 :: Int) './' False './' \'X' './' Just \'O' './' 'nil'+-- -- @+-- has' :: Has a s => Lens' s a+-- has' = hasLens instance UniqueMember x xs => Has x (Many xs) where hasLens = lens grab replace' --- | Polymorphic version of 'piece''+-- | Polymorphic version of 'has'' class (Has a s, Replaced a a s ~ s) => Had a s where type Replaced a b s- piece :: Lens s (Replaced a b s) a b+ hadLens :: Lens s (Replaced a b s) a b instance (UniqueMember x xs) => Had x (Many xs) where type Replaced x b (Many xs) = Many (Replace x b xs)- piece = lens grab (replace @x)+ hadLens = lens grab (replace @x) -pieceTag' :: forall l a s. Has (Tagged l a) s => Lens' s a-pieceTag' = piece' @(Tagged l a) . iso unTagged Tagged+hasTag :: forall l a s. Has (Tagged l a) s => Lens' s a+hasTag = hasLens @(Tagged l a) . iso unTagged Tagged -pieceTag :: forall l a b s. Had (Tagged l a) s+hadTag :: forall l a b s. Had (Tagged l a) s => Lens s (Replaced (Tagged l a) (Tagged l b) s) a b-pieceTag = piece @(Tagged l a) . iso unTagged (Tagged @l)+hadTag = hadLens @(Tagged l a) . iso unTagged (Tagged @l) --- | 'grabL' ('view' 'pieceL') and 'replaceL' ('set' 'pieceL') in 'Lens'' form.+-- | 'grabL' ('view' 'hasL') and 'replaceL' ('set' 'hasL') in 'Lens'' form. -- -- @ -- let x = (5 :: Int) './' Tagged \@Foo False './' Tagged \@Bar \'X' './' 'nil'--- x '^.' 'pieceL'' \@Foo \`shouldBe` Tagged \@Foo False--- (x '&' 'pieceL'' \@Foo '.~' Tagged \@Foo True) \`shouldBe` (5 :: Int) './' Tagged \@Foo True './' Tagged \@Bar \'X' './' 'nil'+-- x '^.' 'hasL'' \@Foo \`shouldBe` Tagged \@Foo False+-- (x '&' 'hasL'' \@Foo '.~' Tagged \@Foo True) \`shouldBe` (5 :: Int) './' Tagged \@Foo True './' Tagged \@Bar \'X' './' 'nil' -- @ -- -- A default implementation using generics is not provided as it make GHC think that @l@ must be type @Symbol@ -- when @l@ can actually be any kind. -- Create instances of 'HasL' using "Data.Generics.Product.Fields" as follows: -- @--- instance HasField' l Foo a => pieceL' l a Foo where--- pieceL' = field @l--- default pieceL' :: forall (l :: Symbol) a s. (HasField' l s a) => Lens' s a--- pieceL' = field @l+-- instance HasField' l Foo a => hasL' l a Foo where+-- hasL' = field @l+-- default hasL' :: forall (l :: Symbol) a s. (HasField' l s a) => Lens' s a+-- hasL' = field @l class HasL (l :: k) a s | s l -> a where- pieceL' :: Lens' s a+ hasL :: Lens' s a instance (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => HasL l x (Many xs) where- pieceL' = lens (grabL @l) (replaceL' @l)+ hasL = lens (grabL @l) (replaceL' @l) --- | Polymorphic version of 'pieceL''+-- | Polymorphic version of 'hasL'' -- -- @ -- let x = (5 :: Int) './' Tagged @Foo False './' Tagged \@Bar \'X' './' 'nil'--- (x '&' 'pieceL' \@Foo '.~' \"foo") \`shouldBe` (5 :: Int) './' \"foo" './' Tagged \@Bar \'X' './' 'nil'+-- (x '&' 'hasL' \@Foo '.~' \"foo") \`shouldBe` (5 :: Int) './' \"foo" './' Tagged \@Bar \'X' './' 'nil' -- @ class (HasL (l :: k) a s, ReplacedL l a a s ~ s) => HadL (l :: k) a s | s l -> a where type ReplacedL l a b s- pieceL :: Lens s (ReplacedL l a b s) a b+ hadL :: Lens s (ReplacedL l a b s) a b instance (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => HadL l x (Many xs) where type ReplacedL l x b (Many xs) = Many (Replace (KindAtLabel l xs) b xs)- pieceL = lens (grabL @l) (replaceL @l)+ hadL = lens (grabL @l) (replaceL @l) --- | 'grabN' ('view' 'piece') and 'replaceN'' ('set' 'piece'') in 'Lens'' form.+-- | 'grabN' ('view' 'has') and 'replaceN'' ('set' 'has'') in 'Lens'' form. -- -- @ -- let x = (5 :: Int) './' False './' \'X' './' Just \'O' './' (6 :: Int) './' Just \'A' ./ nil--- x '^.' 'pieceN'' \@0 \`shouldBe` 5--- (x '&' 'pieceN'' \@0 '.~' 6) \`shouldBe` (6 :: Int) './' False './' \'X' './' Just \'O' './' (6 :: Int) './' Just \'A' './' 'nil'+-- x '^.' 'hasN'' \@0 \`shouldBe` 5+-- (x '&' 'hasN'' \@0 '.~' 6) \`shouldBe` (6 :: Int) './' False './' \'X' './' Just \'O' './' (6 :: Int) './' Just \'A' './' 'nil' -- @ class HasN (n :: Nat) a s | s n -> a where- pieceN' :: Lens' s a+ hasN :: Lens' s a instance (MemberAt n x xs) => HasN n x (Many xs) where- pieceN' = lens (grabN @n) (replaceN' @n)+ hasN = lens (grabN @n) (replaceN' @n) --- | Polymorphic version of 'pieceN''+-- | Polymorphic version of 'hasN'' class (HasN (n :: Nat) a s, ReplacedN n a a s ~ s) => HadN (n :: Nat) a s | s n -> a where type ReplacedN n a b s- pieceN :: Lens s (ReplacedN n a b s) a b+ hadN :: Lens s (ReplacedN n a b s) a b - -- -- | Make it easy to create an instance of 'pieceN' using 'Data.Generics.Product.Positions'- -- default pieceN :: (HasPosition n s (ReplacedN n a b s) a b) => Lens s (ReplacedN n a b s) a b- -- pieceN = position @n+ -- -- | Make it easy to create an instance of 'hasN' using 'Data.Generics.Product.Positions'+ -- default hasN :: (HasPosition n s (ReplacedN n a b s) a b) => Lens s (ReplacedN n a b s) a b+ -- hasN = position @n instance (MemberAt n x xs) => HadN n x (Many xs) where type ReplacedN n x b (Many xs) = Many (ReplaceIndex n x b xs)- pieceN = lens (grabN @n) (replaceN @n)+ hadN = lens (grabN @n) (replaceN @n) -----------------------------------------------------------------------
src/Data/Diverse/Profunctor/Many.hs view
@@ -10,9 +10,9 @@ module Data.Diverse.Profunctor.Many ( -- * Combinators similar to Profunctor Strong- Pieced- , pieced- , piecedK+ Have+ , have+ , haveK , Projected , projected , projectedK@@ -32,30 +32,30 @@ import Data.Diverse.TypeLevel import Data.Profunctor --- | A friendlier constraint synonym for 'pieced'.-type Pieced a b s t =+-- | A friendlier constraint synonym for 'have'.+type Have a b s t = ( Had a s , t ~ Replaced a b s ) -- | Like 'Strong' or 'Arrow' but lifting into 'Many'-pieced ::+have :: forall w a b s t. ( Profunctor w , Strong w- , Pieced a b s t+ , Have a b s t ) => w a b -> w s t-pieced w = dimap (\c -> (view piece' c, c)) (\(b, c) -> set (piece @a) b c) (first' w)+have w = dimap (\c -> (view hasLens c, c)) (\(b, c) -> set (hadLens @a) b c) (first' w) --- | 'pieced' under 'Kleisli'-piecedK ::+-- | 'have' under 'Kleisli'+haveK :: forall m a b s t. ( Monad m- , Pieced a b s t+ , Have a b s t ) => (a -> m b) -> (s -> m t)-piecedK f = runKleisli . pieced $ Kleisli f+haveK f = runKleisli . have $ Kleisli f -- | A friendlier constraint synonym for 'projected'. type Projected a1 a2 b1 b2 =
src/Data/Diverse/Profunctor/Which.hs view
@@ -22,9 +22,6 @@ , thenChoose , thenChooseK , chooseWith- -- , (+||+)- -- , (>||>)- -- , (<||<) ) where import Control.Arrow@@ -93,17 +90,6 @@ , b3 ~ AppendUnique b1 b2 ) --- chooseBoth ::--- ( C.Category w--- , Strong w--- , ChooseBoth b1 b2 b3--- )--- => w a (Which b1)--- -> w a (Which b2)--- -> w a (Which b3, Which b3)--- chooseBoth x y = lmap (\a -> (a, a)) (first' (rmap diversify x)) C.>>> (second' (rmap diversify y))--- infixr 2 `chooseBoth` -- like +++- -- | A friendlier constraint synonym for 'chooseFrom'. -- Redundant constraint: @a3 ~ Append a1 a2@ is redundant but narrows down @a3@ type ChooseFrom a1 a2 a3 =@@ -112,12 +98,6 @@ , a3 ~ Append a1 a2 ) --- -- | A friendlier constraint synonym for 'chooseBetween'.--- type ChooseBetween a1 a2 a3 b1 b2 b3 =--- ( ChooseFrom a1 a2 a3--- , ChooseBoth b1 b2 b3--- )- -- | Split the input between the two argument arrows, retagging and merging their outputs. -- The output is merged into a 'Which' of unique types. -- Analogous to a 'Which' combination of both 'Control.Arrow.+++' and 'Control.Arrow.|||'.@@ -149,17 +129,6 @@ chooseBetweenK f g = runKleisli $ chooseBetween (Kleisli f) (Kleisli g) infixr 2 `chooseBetweenK` -- like +++ --- (+||+) ::--- ( C.Category w--- , Choice w--- , ChooseBetween a1 a2 a3 b1 b2 b3--- )--- => w (Which a1) (Which b1)--- -> w (Which a2) (Which b2)--- -> w (Which a3) (Which b3)--- (+||+) = chooseBetween--- infixr 2 +||+ -- like +++- -- | Left-to-right chaining of arrows one after another, where left over possibilities not handled -- by the right arrow is forwarded to the output. -- It is a compile error if the types are not distinct in each of the argument arrow inputs,@@ -187,23 +156,9 @@ thenChooseK f g = runKleisli $ thenChoose (Kleisli f) (Kleisli g) infixr 2 `thenChooseK` -- like +++ --- -- | right-to-left version of '(>||>)'--- (<||<)--- :: forall w a a2 b1 b2 b3.--- ( C.Category w--- , Choice w--- , Injected a2 b1 b2 b3--- )--- => w (Which a2) (Which b2)--- -> w a (Which b1)--- -> w a (Which b3)--- (<||<) = flip (>||>)--- infixr 2 <||< -- like >||>- ------------------------------------------ chooseWith :: (Functor f, ChooseBoth a1 a2 a3) => (f (Which a3) -> f (Which a3) -> f (Which a3)) -> f (Which a1) -> f (Which a2) -> f (Which a3) chooseWith f x y = (diversify <$> x) `f` (diversify <$> y) infixr 6 `chooseWith` -- like mappend-
test/Data/Diverse/Lens/ManySpec.hs view
@@ -32,55 +32,55 @@ x `shouldBe` review _Many' t t `shouldBe` view _Many' x - it "has getter/setter lens using 'piece''" $ do+ it "has getter/setter lens using 'hasLens'" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil- x ^. piece' @Int `shouldBe` 5- (x & piece' @Int .~ 6) `shouldBe` (6 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil- x ^. piece' @Bool `shouldBe` False- (x & piece' @Bool .~ True) `shouldBe` (5 :: Int) ./ True ./ 'X' ./ Just 'O' ./ nil- x ^. piece' @Char `shouldBe` 'X'- x ^. piece' @(Maybe Char) `shouldBe` Just 'O'+ x ^. hasLens @Int `shouldBe` 5+ (x & hasLens @Int .~ 6) `shouldBe` (6 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil+ x ^. hasLens @Bool `shouldBe` False+ (x & hasLens @Bool .~ True) `shouldBe` (5 :: Int) ./ True ./ 'X' ./ Just 'O' ./ nil+ x ^. hasLens @Char `shouldBe` 'X'+ x ^. hasLens @(Maybe Char) `shouldBe` Just 'O' - it "has polymorphic getter/setter lens using 'piece'" $ do+ it "has polymorphic getter/setter lens using 'hasLens" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil- (x & piece @(Maybe Char) .~ Just 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'P' ./ nil- (x & piece @Int .~ 'Z') `shouldBe` 'Z' ./ False ./ 'X' ./ Just 'O' ./ nil- (x & piece @Bool .~ 'Z') `shouldBe` (5 :: Int) ./ 'Z' ./ 'X' ./ Just 'O' ./ nil- (x & piece @Char .~ True) `shouldBe` (5 :: Int) ./ False ./ True ./ Just 'O' ./ nil- (x & piece @(Maybe Char) .~ 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ 'P' ./ nil+ (x & hadLens @(Maybe Char) .~ Just 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'P' ./ nil+ (x & hadLens @Int .~ 'Z') `shouldBe` 'Z' ./ False ./ 'X' ./ Just 'O' ./ nil+ (x & hadLens @Bool .~ 'Z') `shouldBe` (5 :: Int) ./ 'Z' ./ 'X' ./ Just 'O' ./ nil+ (x & hadLens @Char .~ True) `shouldBe` (5 :: Int) ./ False ./ True ./ Just 'O' ./ nil+ (x & hadLens @(Maybe Char) .~ 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ 'P' ./ nil - it "has getter/setter lens using 'pieceL''" $ do+ it "has getter/setter lens using 'hasL'" $ do let x = (5 :: Int) ./ Tagged @Foo False ./ Tagged @Bar 'X' ./ nil- x ^. pieceL' @Foo `shouldBe` Tagged @Foo False- (x & pieceL' @Foo .~ Tagged @Foo True) `shouldBe` (5 :: Int) ./ Tagged @Foo True ./ Tagged @Bar 'X' ./ nil+ x ^. hasL @Foo `shouldBe` Tagged @Foo False+ (x & hasL @Foo .~ Tagged @Foo True) `shouldBe` (5 :: Int) ./ Tagged @Foo True ./ Tagged @Bar 'X' ./ nil - it "has polymorphic getter/setter lens using 'pieceL'" $ do+ it "has polymorphic getter/setter lens using 'hasL" $ do let x = (5 :: Int) ./ Tagged @Foo False ./ Tagged @Bar 'X' ./ nil- (x & pieceL @Foo .~ "foo") `shouldBe` (5 :: Int) ./ "foo" ./ Tagged @Bar 'X' ./ nil+ (x & hadL @Foo .~ "foo") `shouldBe` (5 :: Int) ./ "foo" ./ Tagged @Bar 'X' ./ nil - it "has getter/setter lens for duplicate fields using 'pieceN''" $ do+ it "has getter/setter lens for duplicate fields using 'hasN'" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @0 `shouldBe` 5- (x & pieceN' @0 .~ 6) `shouldBe` (6 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @1 `shouldBe` False- (x & pieceN' @1 .~ True) `shouldBe` (5 :: Int) ./ True ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @2 `shouldBe` 'X'- (x & pieceN' @2 .~ 'O') `shouldBe` (5 :: Int) ./ False ./ 'O' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @3 `shouldBe` Just 'O'- (x & pieceN' @3 .~ Just 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'P' ./ (6 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @4 `shouldBe` 6- (x & pieceN' @4 .~ 7) `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (7 :: Int) ./ Just 'A' ./ nil- x ^. pieceN' @5 `shouldBe` Just 'A'- (x & pieceN' @5 .~ Just 'B') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'B' ./ nil+ x ^. hasN @0 `shouldBe` 5+ (x & hasN @0 .~ 6) `shouldBe` (6 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ x ^. hasN @1 `shouldBe` False+ (x & hasN @1 .~ True) `shouldBe` (5 :: Int) ./ True ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ x ^. hasN @2 `shouldBe` 'X'+ (x & hasN @2 .~ 'O') `shouldBe` (5 :: Int) ./ False ./ 'O' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ x ^. hasN @3 `shouldBe` Just 'O'+ (x & hasN @3 .~ Just 'P') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'P' ./ (6 :: Int) ./ Just 'A' ./ nil+ x ^. hasN @4 `shouldBe` 6+ (x & hasN @4 .~ 7) `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (7 :: Int) ./ Just 'A' ./ nil+ x ^. hasN @5 `shouldBe` Just 'A'+ (x & hasN @5 .~ Just 'B') `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'B' ./ nil - it "has polymorphic getter/setter lens for duplicate fields using 'pieceN'" $ do+ it "has polymorphic getter/setter lens for duplicate fields using 'hasN" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- (x & pieceN @0 .~ "Foo") `shouldBe` "Foo" ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- (x & pieceN @1 .~ "Foo") `shouldBe` (5 :: Int) ./ "Foo" ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- (x & pieceN @2 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ "Foo" ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil- (x & pieceN @3 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ "Foo" ./ (6 :: Int) ./ Just 'A' ./ nil- (x & pieceN @4 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ "Foo" ./ Just 'A' ./ nil- (x & pieceN @5 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ "Foo" ./ nil+ (x & hadN @0 .~ "Foo") `shouldBe` "Foo" ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ (x & hadN @1 .~ "Foo") `shouldBe` (5 :: Int) ./ "Foo" ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ (x & hadN @2 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ "Foo" ./ Just 'O' ./ (6 :: Int) ./ Just 'A' ./ nil+ (x & hadN @3 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ "Foo" ./ (6 :: Int) ./ Just 'A' ./ nil+ (x & hadN @4 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ "Foo" ./ Just 'A' ./ nil+ (x & hadN @5 .~ "Foo") `shouldBe` (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ (6 :: Int) ./ "Foo" ./ nil it "has getter/setter lens for multiple fields using 'project''" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil