data-diverse 3.1.0.0 → 4.0.0.0
raw patch · 5 files changed
+42/−39 lines, 5 filesdep ~taggedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: tagged
API changes (from Hackage documentation)
- Data.Diverse.Many: postfix :: Many xs -> y -> Many (Append xs '[y])
- Data.Diverse.Many: postfix' :: forall y xs. MaybeUniqueMember y xs => Many xs -> y -> Many (SnocUnique xs y)
- Data.Diverse.Many: prefix :: x -> Many xs -> Many (x : xs)
- Data.Diverse.Many.Internal: postfix :: Many xs -> y -> Many (Append xs '[y])
- Data.Diverse.Many.Internal: postfix' :: forall y xs. MaybeUniqueMember y xs => Many xs -> y -> Many (SnocUnique xs y)
- Data.Diverse.Many.Internal: prefix :: x -> Many xs -> Many (x : xs)
+ Data.Diverse.Many: consMany :: x -> Many xs -> Many (x : xs)
+ Data.Diverse.Many: snocMany :: Many xs -> y -> Many (Append xs '[y])
+ Data.Diverse.Many: snocMany' :: forall y xs. MaybeUniqueMember y xs => Many xs -> y -> Many (SnocUnique xs y)
+ Data.Diverse.Many.Internal: consMany :: x -> Many xs -> Many (x : xs)
+ Data.Diverse.Many.Internal: snocMany :: Many xs -> y -> Many (Append xs '[y])
+ Data.Diverse.Many.Internal: snocMany' :: forall y xs. MaybeUniqueMember y xs => Many xs -> y -> Many (SnocUnique xs y)
Files
- README.md +3/−0
- data-diverse.cabal +3/−3
- src/Data/Diverse/Many.hs +3/−3
- src/Data/Diverse/Many/Internal.hs +25/−25
- test/Data/Diverse/ManySpec.hs +8/−8
README.md view
@@ -14,6 +14,9 @@ # Changelog +* 4.0.0.0+ - Renamed `prefix` to `consMany` and `postfix` to `snocMany`.+ * 3.1.0.0 - Removed `Read` instance for `Which []` since it is uninhabitable. - `xxxTag` functions only rely on `UniqueMember`, not `UniqueLabelMember`
data-diverse.cabal view
@@ -1,5 +1,5 @@ name: data-diverse-version: 3.1.0.0+version: 4.0.0.0 synopsis: Extensible records and polymorphic variants. description: "Data.Diverse.Many" is an extensible record for any size encoded efficiently as (Seq Any). "Data.Diverse.Which" is a polymorphic variant of possibilities encoded as (Int, Any).@@ -42,7 +42,7 @@ , containers >= 0.5 , deepseq >= 1.4 , ghc-prim >= 0.5- , tagged >= 0.8.5+ , tagged >= 0.8 ghc-options: -Wall default-language: Haskell2010 @@ -56,7 +56,7 @@ build-depends: base , data-diverse , hspec >= 2- , tagged >= 0.8.5+ , tagged >= 0.8 ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall default-language: Haskell2010
src/Data/Diverse/Many.hs view
@@ -13,10 +13,10 @@ -- * Construction , nil , single- , prefix+ , consMany , (./)- , postfix- , postfix'+ , snocMany+ , snocMany' , (\.) , append -- , CanAppendUnique(..)
src/Data/Diverse/Many/Internal.hs view
@@ -32,10 +32,10 @@ -- * Construction , nil , single- , prefix+ , consMany , (./)- , postfix- , postfix'+ , snocMany+ , snocMany' , (\.) , append -- , CanAppendUnique(..)@@ -145,7 +145,7 @@ -- This encoding should reasonabily efficient for any number of fields. -- -- The map Key is index + offset of the type in the typelist.--- The Offset is used to allow efficient cons 'prefix'.+-- The Offset is used to allow efficient cons 'consMany'. -- -- @Key = Index of type in typelist + Offset@ --@@ -300,46 +300,46 @@ -- | Add an element to the left of a Many. -- Not named @cons@ to avoid conflict with 'Control.Lens.cons'-prefix :: x -> Many xs -> Many (x ': xs)-prefix x (Many rs) = Many ((unsafeCoerce x) S.<| rs)-infixr 5 `prefix`+consMany :: x -> Many xs -> Many (x ': xs)+consMany x (Many rs) = Many ((unsafeCoerce x) S.<| rs)+infixr 5 `consMany` -prefix_ :: x -> Many_ xs -> Many_ (x ': xs)-prefix_ x (Many_ xs) = Many_ (unsafeCoerce x : xs)+consMany_ :: x -> Many_ xs -> Many_ (x ': xs)+consMany_ x (Many_ xs) = Many_ (unsafeCoerce x : xs) --- | Infix version of 'prefix'.+-- | Infix version of 'consMany'. -- -- Mnemonic: Element on the left is smaller './' than the larger 'Many' to the right. (./) :: x -> Many xs -> Many (x ': xs)-(./) = prefix+(./) = consMany infixr 5 ./ -- like Data.List.(:) -- | Add an element to the right of a Many -- Not named @snoc@ to avoid conflict with 'Control.Lens.snoc'-postfix :: Many xs -> y -> Many (Append xs '[y])-postfix (Many ls) y = Many (ls S.|> (unsafeCoerce y))-infixl 5 `postfix`+snocMany :: Many xs -> y -> Many (Append xs '[y])+snocMany (Many ls) y = Many (ls S.|> (unsafeCoerce y))+infixl 5 `snocMany` -- | Add an element to the right of a Many iff the field doesn't already exist.-postfix'+snocMany' :: forall y xs. MaybeUniqueMember y xs => Many xs -> y -> Many (SnocUnique xs y)-postfix'(Many ls) y = if i /= 0 then Many ls else Many (ls S.|> unsafeCoerce y)+snocMany'(Many ls) y = if i /= 0 then Many ls else Many (ls S.|> unsafeCoerce y) where i = fromInteger (natVal @(PositionOf y xs) Proxy) :: Int-infixl 5 `postfix'`+infixl 5 `snocMany'` --- | Infix version of 'postfix'.+-- | Infix version of 'snocMany'. -- -- Mnemonic: Many is larger '\.' than the smaller element (\.) :: Many xs -> y -> Many (Append xs '[y])-(\.) = postfix+(\.) = snocMany infixl 5 \. -- | Infix version of 'append'. ----- Mnemonic: 'prefix' './' with an extra slash (meaning 'Many') in front.+-- Mnemonic: 'consMany' './' with an extra slash (meaning 'Many') in front. (/./) :: Many xs -> Many ys -> Many (Append xs ys) (/./) = append infixr 5 /./ -- like (++)@@ -350,7 +350,7 @@ infixr 5 `append` -- like Data.List (++) -- class CanAppendUnique xs ys where--- -- | Appends the unique fields fields from the right Many using 'postfix''+-- -- | Appends the unique fields fields from the right Many using 'snocMany'' -- append' :: Many xs -> Many ys -> Many (AppendUnique xs ys) -- instance CanAppendUnique xs '[] where@@ -359,7 +359,7 @@ -- instance ( MaybeUniqueMember y xs -- , CanAppendUnique (SnocUnique xs y) ys -- , AppendUnique (SnocUnique xs y) ys ~ AppendUnique xs (y : ys)) => CanAppendUnique xs (y ': ys) where--- append' ls rs = append' (postfix' ls r) rs'+-- append' ls rs = append' (snocMany' ls r) rs' -- where (r, rs') = viewf rs -- {-# INLINABLE append' #-} -- This makes compiling tests a little faster than with no pragma @@ -1099,7 +1099,7 @@ showString " ./ " . showsPrec cons_prec (aft_ ls) -- not (cons-prec+1) for right associativity where- cons_prec = 5 -- infixr 5 prefix+ cons_prec = 5 -- infixr 5 consMany -- use of front here is safe as we are guaranteed the length from the typelist v = unsafeCoerce (Partial.head xs) :: x {-# INLINABLE showsPrec #-} -- This makes compiling tests a little faster than with no pragma@@ -1122,9 +1122,9 @@ a <- step (readPrec @x) lift $ L.expect (Symbol "./") as <- readPrec @(Many_ xs) -- no 'step' to allow right associatitive './'- pure $ prefix_ a as+ pure $ consMany_ a as where- cons_prec = 5 -- infixr `prefix`+ cons_prec = 5 -- infixr `consMany` {-# INLINABLE readPrec #-} -- This makes compiling tests a little faster than with no pragma -- | @read "5 ./ False ./ 'X' ./ Just 'O' ./ nil" == (5 :: Int) './' False './' \'X' './' Just \'O' './' 'nil'@
test/Data/Diverse/ManySpec.hs view
@@ -85,22 +85,22 @@ x `shouldBe` toMany' t t `shouldBe` fromMany' x - it "can construct using 'single', 'nil', 'prefix', 'postfix', 'append'" $ do+ it "can construct using 'single', 'nil', 'consMany', 'snocMany', 'append'" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil- x' = (5 :: Int) `prefix` False `prefix` 'X' `prefix` Just 'O' `prefix` nil+ x' = (5 :: Int) `consMany` False `consMany` 'X' `consMany` Just 'O' `consMany` nil y = single (5 :: Int) \. False \. 'X' \. Just 'O'- y' = single (5 :: Int) `postfix` False `postfix` 'X' `postfix` Just 'O'- a = single (5 :: Int) `postfix` False- b = single 'X' `postfix` Just 'O'+ y' = single (5 :: Int) `snocMany` False `snocMany` 'X' `snocMany` Just 'O'+ a = single (5 :: Int) `snocMany` False+ b = single 'X' `snocMany` Just 'O' x `shouldBe` y x `shouldBe` x' y `shouldBe` y' a /./ b `shouldBe` x a `append` b `shouldBe` x - it "can 'postfix'' a value only if that type doesn't already exist" $ do+ it "can 'snocMany'' a value only if that type doesn't already exist" $ do let x = (5 :: Int) ./ False ./ 'X' ./ Just 'O' ./ nil- y = x `postfix'` True+ y = x `snocMany'` True y `shouldBe` x -- it "can 'append'' the unique types from another Many" $ do@@ -326,7 +326,7 @@ afoldr (:) [] (collectN x (casesN y)) `shouldBe` ret afoldr (:) [] (forManyN (casesN y) x) `shouldBe` ret - it "every item can be mapped into a different type in a Functor-like fashion with using 'afmap'" $ do+ it "every piece can be mapped into a different type in a Functor-like fashion with using 'afmap'" $ do let x = (5 :: Int) ./ (6 :: Int8) ./ (7 :: Int16) ./ (8 :: Int32) ./ nil y = (15 :: Int) ./ (16 :: Int8) ./ (17 :: Int16) ./ (18 :: Int32) ./ nil z = ("5" :: String) ./ ("6" :: String) ./ ("7" :: String) ./ ("8" :: String) ./ nil