data-diverse-lens 0.1.1.0 → 0.3.0.0
raw patch · 5 files changed
+40/−37 lines, 5 filesdep ~data-diversePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: data-diverse
API changes (from Hackage documentation)
- Data.Diverse.Lens.Many: project' :: forall smaller smaller' larger zipped. (Select smaller larger, Amend' smaller smaller' larger zipped) => Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
+ Data.Diverse.Lens.Many: project' :: forall smaller smaller' larger. (Select smaller larger, Amend' smaller smaller' larger) => Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
- Data.Diverse.Lens.Many: projectL' :: forall ls smaller smaller' larger proxy zipped. (Select smaller larger, Amend' smaller smaller' larger zipped, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
+ Data.Diverse.Lens.Many: projectL' :: forall ls smaller smaller' larger proxy. (Select smaller larger, Amend' smaller smaller' larger, smaller ~ KindsAtLabels ls larger, IsDistinct ls, UniqueLabels ls larger) => proxy ls -> Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller')
- Data.Diverse.Lens.Many: projectN' :: forall ns smaller smaller' larger proxy zipped. (SelectN ns smaller larger, AmendN' ns smaller smaller' larger zipped) => proxy ns -> Lens (Many larger) (Many (ReplacesIndex ns smaller' larger)) (Many smaller) (Many smaller')
+ Data.Diverse.Lens.Many: projectN' :: forall ns smaller smaller' larger proxy. (SelectN ns smaller larger, AmendN' ns smaller smaller' larger) => proxy ns -> Lens (Many larger) (Many (ReplacesIndex ns smaller' larger)) (Many smaller) (Many smaller')
- Data.Diverse.Lens.Which: facetL :: forall l xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Prism' (Which xs) x
+ Data.Diverse.Lens.Which: facetL :: forall l x xs proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Prism' (Which xs) x
- Data.Diverse.Lens.Which: facetN :: forall n xs x proxy. (MemberAt n x xs) => proxy n -> Prism' (Which xs) x
+ Data.Diverse.Lens.Which: facetN :: forall n x xs proxy. (MemberAt n x xs) => proxy n -> Prism' (Which xs) x
- Data.Diverse.Lens.Which: inject :: forall branch tree. (Diversify tree branch, Reinterpret branch tree) => Prism' (Which tree) (Which branch)
+ Data.Diverse.Lens.Which: inject :: forall branch tree. (Diversify branch tree, Reinterpret' branch tree) => Prism' (Which tree) (Which branch)
- Data.Diverse.Lens.Which: injectL :: forall ls branch tree proxy. (Diversify tree branch, Reinterpret branch tree, branch ~ KindsAtLabels ls tree, UniqueLabels ls tree, IsDistinct ls) => proxy ls -> Prism' (Which tree) (Which branch)
+ Data.Diverse.Lens.Which: injectL :: forall ls branch tree proxy. (Diversify branch tree, Reinterpret' branch tree, branch ~ KindsAtLabels ls tree, UniqueLabels ls tree, IsDistinct ls) => proxy ls -> Prism' (Which tree) (Which branch)
- Data.Diverse.Lens.Which: injectN :: forall indices branch tree proxy. (DiversifyN indices tree branch, ReinterpretN indices branch tree) => proxy indices -> Prism' (Which tree) (Which branch)
+ Data.Diverse.Lens.Which: injectN :: forall indices branch tree proxy. (DiversifyN indices branch tree, ReinterpretN' indices branch tree) => proxy indices -> Prism' (Which tree) (Which branch)
Files
- README.md +9/−0
- data-diverse-lens.cabal +3/−3
- src/Data/Diverse/Lens/Many.hs +6/−6
- src/Data/Diverse/Lens/Which.hs +20/−26
- test/Data/Diverse/Lens/WhichSpec.hs +2/−2
README.md view
@@ -4,3 +4,12 @@ Provides "Iso"s & 'Len's for "Data.Diverse.Many" and 'Prism's 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/blob/master/test/Data/Diverse/Lens/WhichSpec.hs) for example usages.+++# Changelog++* pre 0.3.0.0+ - Initial version represented as (Int, Data.Map Int Any)++* 0.3.0.0+ - Changed type variable ordering of 'facetL' and 'facetN', so it's consistently 'x' then 'xs'
data-diverse-lens.cabal view
@@ -1,5 +1,5 @@ name: data-diverse-lens-version: 0.1.1.0+version: 0.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.@@ -21,7 +21,7 @@ Data.Diverse.Lens.Many Data.Diverse.Lens.Which build-depends: base >= 4.7 && < 5- , data-diverse >= 0.6 && < 1+ , data-diverse >= 0.10 && < 1 , lens >= 4 && < 5 , tagged >= 0.8.5 && < 1 ghc-options: -Wall@@ -34,7 +34,7 @@ other-modules: Data.Diverse.Lens.ManySpec Data.Diverse.Lens.WhichSpec build-depends: base- , data-diverse >= 0.6 && < 1+ , data-diverse >= 0.10 && < 1 , data-diverse-lens , hspec >= 2 && < 3 , lens >= 4 && < 5
src/Data/Diverse/Lens/Many.hs view
@@ -118,8 +118,8 @@ -- | Polymorphic version of project' project'- :: forall smaller smaller' larger zipped.- (Select smaller larger, Amend' smaller smaller' larger zipped)+ :: forall smaller smaller' larger.+ (Select smaller larger, Amend' smaller smaller' larger) => Lens (Many larger) (Many (Replaces smaller smaller' larger)) (Many smaller) (Many smaller') project' = lens select (amend' @smaller @smaller' Proxy) @@ -149,9 +149,9 @@ -- False './' True './' Tagged \@Foo False './' Tagged \@Bar \'X' './' Tagged \@\"Changed" False './' 'nil' -- @ projectL'- :: forall ls smaller smaller' larger proxy zipped.+ :: forall ls smaller smaller' larger proxy. ( Select smaller larger- , Amend' smaller smaller' larger zipped+ , Amend' smaller smaller' larger , smaller ~ KindsAtLabels ls larger , IsDistinct ls , UniqueLabels ls larger)@@ -178,7 +178,7 @@ -- | Polymorphic version of 'projectN' projectN'- :: forall ns smaller smaller' larger proxy zipped.- (SelectN ns smaller larger, AmendN' ns smaller smaller' larger zipped)+ :: forall ns smaller smaller' larger proxy.+ (SelectN ns smaller larger, AmendN' ns smaller smaller' larger) => proxy ns -> Lens (Many larger) (Many (ReplacesIndex ns smaller' larger)) (Many smaller) (Many smaller') projectN' p = lens (selectN p) (amendN' p)
src/Data/Diverse/Lens/Which.hs view
@@ -23,16 +23,10 @@ ----------------------------------------------------------------- --- | Utility to convert Either to Maybe-hush :: Either a b -> Maybe b-hush = either (const Nothing) Just-------------------------------------------------------------------- -- | 'pick' ('review' 'facet') and 'trial' ('preview' 'facet') in 'Prism'' form. -- -- @--- 'facet' = 'prism'' 'pick' (either (const Nothing) Just . 'trial')+-- 'facet' = 'prism'' 'pick' ('trial'') -- @ -- -- @@@ -41,22 +35,22 @@ -- x \`shouldBe` (Just 5) -- @ facet :: forall x xs. (UniqueMember x xs) => Prism' (Which xs) x-facet = prism' pick (hush . trial)+facet = prism' pick trial' --- | 'pickL' ('review' 'facetL') and 'trialL' ('preview' 'facetL') in 'Prism'' form.+-- | 'pickL' ('review' 'facetL') and 'trialL'' ('preview' 'facetL'') in 'Prism'' form. -- -- @ -- let y = 'review' ('facetL' \@Bar Proxy) (Tagged (5 :: Int)) :: Which '[Tagged Foo Bool, Tagged Bar Int, Char, Bool, Char] -- x = 'preview' ('facetL' \@Bar Proxy) y -- x \`shouldBe` (Just (Tagged 5)) -- @-facetL :: forall l xs x proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Prism' (Which xs) x-facetL p = prism' (pickL p) (hush . trialL p)+facetL :: forall l x xs proxy. (UniqueLabelMember l xs, x ~ KindAtLabel l xs) => proxy l -> Prism' (Which xs) x+facetL p = prism' (pickL p) (trialL' p) -- | 'pickN' ('review' 'facetN') and 'trialN' ('preview' 'facetN') in 'Prism'' form. -- -- @--- 'facetN' p = 'prism'' ('pickN' p) (either (const Nothing) Just . 'trialN' p)+-- 'facetN' p = 'prism'' ('pickN' p) ('trialN'' p) -- @ -- -- @@@ -64,13 +58,13 @@ -- x = 'preview' ('facetN' (Proxy \@4)) y -- 'trialN' -- x \`shouldBe` (Just 5) -- @-facetN :: forall n xs x proxy. (MemberAt n x xs) => proxy n -> Prism' (Which xs) x-facetN p = prism' (pickN p) (hush . trialN p)+facetN :: forall n x xs proxy. (MemberAt n x xs) => proxy n -> Prism' (Which xs) x+facetN p = prism' (pickN p) (trialN' p) ------------------------------------------------------------------ --- | 'diversify' ('review' 'inject') and 'reinterpret' ('preview' 'inject') in 'Prism'' form.+-- | 'diversify' ('review' 'inject') and 'reinterpret'' ('preview' 'inject') in 'Prism'' form. -- -- @ -- let x = 'pick' (5 :: Int) :: 'Which' '[String, Int]@@ -81,13 +75,13 @@ -- @ inject :: forall branch tree.- ( Diversify tree branch- , Reinterpret branch tree+ ( Diversify branch tree+ , Reinterpret' branch tree ) => Prism' (Which tree) (Which branch)-inject = prism' diversify (hush . reinterpret)+inject = prism' diversify reinterpret' --- | 'diversifyL' ('review' 'injectL') and 'reinterpretL' ('preview' 'injectL') in 'Prism'' form.+-- | 'diversifyL' ('review' 'injectL') and 'reinterpretL'' ('preview' 'injectL') in 'Prism'' form. -- -- @ -- let t = 'pick' \@[Tagged Bar Int, Tagged Foo Bool, Tagged Hi Char, Tagged Bye Bool] (5 :: Tagged Bar Int)@@ -99,16 +93,16 @@ -- @ injectL :: forall ls branch tree proxy.- ( Diversify tree branch- , Reinterpret branch tree+ ( Diversify branch tree+ , Reinterpret' branch tree , branch ~ KindsAtLabels ls tree , UniqueLabels ls tree , IsDistinct ls ) => proxy ls -> Prism' (Which tree) (Which branch)-injectL p = prism' (diversifyL p) (hush . reinterpretL p)+injectL p = prism' (diversifyL p) (reinterpretL' p) --- | 'diversifyN' ('review' 'injectN') and 'reinterpretN' ('preview' 'injectN') in 'Prism'' form.+-- | 'diversifyN' ('review' 'injectN') and 'reinterpretN'' ('preview' 'injectN') in 'Prism'' form. -- -- @ -- let x = 'pick' (5 :: Int) :: 'Which' '[String, Int]@@ -119,8 +113,8 @@ -- @ injectN :: forall indices branch tree proxy.- ( DiversifyN indices tree branch- , ReinterpretN indices branch tree+ ( DiversifyN indices branch tree+ , ReinterpretN' indices branch tree ) => proxy indices -> Prism' (Which tree) (Which branch)-injectN p = prism' (diversifyN p) (reinterpretN p)+injectN p = prism' (diversifyN p) (reinterpretN' p)
test/Data/Diverse/Lens/WhichSpec.hs view
@@ -56,8 +56,8 @@ y' `shouldBe` Just (pick (5 :: Int)) it "can be 'diversifyL'ed and 'reinterpretedL' by label with 'injectL'" $ do- let t = pick @[Tagged Bar Int, Tagged Foo Bool, Tagged Hi Char, Tagged Bye Bool] (5 :: Tagged Bar Int)- b = pick @'[Tagged Foo Bool, Tagged Bar Int] (5 :: Tagged Bar Int)+ let t = pick @_ @[Tagged Bar Int, Tagged Foo Bool, Tagged Hi Char, Tagged Bye Bool] (5 :: Tagged Bar Int)+ b = pick @_ @'[Tagged Foo Bool, Tagged Bar Int] (5 :: Tagged Bar Int) t' = review (injectL @[Foo, Bar] @_ @[Tagged Bar Int, Tagged Foo Bool, Tagged Hi Char, Tagged Bye Bool] Proxy) b b' = preview (injectL @[Foo, Bar] Proxy) t' t `shouldBe` t'