tree-diff 0.2.2 → 0.3
raw patch · 6 files changed
+45/−25 lines, 6 filesdep +data-array-bytedep ~unordered-containers
Dependencies added: data-array-byte
Dependency ranges changed: unordered-containers
Files
- ChangeLog.md +12/−0
- src/Data/TreeDiff/Class.hs +5/−4
- src/Data/TreeDiff/Expr.hs +1/−1
- src/Data/TreeDiff/OMap.hs +4/−6
- tests/Tests.hs +5/−0
- tree-diff.cabal +18/−14
ChangeLog.md view
@@ -1,3 +1,15 @@+## 0.3++- Breaking change:+ Make HashSet and HashMap ToExpr instances sort the resulting+ lists of expressions.+ This makes the results deterministic.+ ... but your golden files will need adjustment.+ https://github.com/haskellari/tree-diff/issues/67++- Add `Ord Expr` and `Ord OMap` instances+- Depend on `data-array-byte` to provide more `ByteArray` instances+ ## 0.2.2 - Add instances for base and primitive's `ByteArray`s.
src/Data/TreeDiff/Class.hs view
@@ -21,6 +21,7 @@ ) where import Data.Foldable (toList)+import Data.List (sort) import Data.List.Compat (uncons) import Data.Proxy (Proxy (..)) import GHC.Generics@@ -108,7 +109,7 @@ -- primitive import qualified Data.Primitive as Prim -#if MIN_VERSION_base(4,17,0)+#if MIN_VERSION_base(4,9,0) import Data.Array.Byte (ByteArray (..)) #endif @@ -550,9 +551,9 @@ ------------------------------------------------------------------------------- instance (ToExpr k, ToExpr v) => ToExpr (HM.HashMap k v) where- toExpr x = App "HM.fromList" [ toExpr $ HM.toList x ]+ toExpr x = App "HM.fromList" [ Lst $ sort $ map toExpr $ HM.toList x ] instance (ToExpr k) => ToExpr (HS.HashSet k) where- toExpr x = App "HS.fromList" [ toExpr $ HS.toList x ]+ toExpr x = App "HS.fromList" [ Lst $ sort $ map toExpr $ HS.toList x ] ------------------------------------------------------------------------------- -- aeson@@ -601,7 +602,7 @@ instance ToExpr Prim.ByteArray where toExpr ba = App "Prim.byteArrayFromList" [toExpr (Prim.foldrByteArray (:) [] ba :: [Word8])] -#if MIN_VERSION_base(4,17,0)+#if MIN_VERSION_base(4,9,0) -- | @since 0.2.2 instance ToExpr ByteArray where toExpr (ByteArray ba) = App "byteArrayFromList" [toExpr (Prim.foldrByteArray (:) [] (Prim.ByteArray ba) :: [Word8])]
src/Data/TreeDiff/Expr.hs view
@@ -35,7 +35,7 @@ = App ConstructorName [Expr] -- ^ application | Rec ConstructorName (OMap FieldName Expr) -- ^ record constructor | Lst [Expr] -- ^ list constructor- deriving (Eq, Show)+ deriving (Eq, Ord, Show) instance NFData Expr where rnf (App n es) = rnf n `seq` rnf es
src/Data/TreeDiff/OMap.hs view
@@ -61,12 +61,10 @@ -- False -- instance (Eq k, Eq v) => Eq (OMap k v) where- xs == ys = go (toAscList xs) (toAscList ys) where- go [] [] = True- go _ [] = False- go [] _ = False- go ((k1, v1) : kvs1) ((k2, v2) : kvs2) =- k1 == k2 && v1 == v2 && go kvs1 kvs2+ xs == ys = toAscList xs == toAscList ys++instance (Ord k, Ord v) => Ord (OMap k v) where+ compare xs ys = compare (toAscList xs) (toAscList ys) ------------------------------------------------------------------------------- -- deepseq
tests/Tests.hs view
@@ -11,6 +11,7 @@ import Test.Tasty.Golden.Advanced (goldenTest) import Test.Tasty.QuickCheck (testProperty) +import qualified Data.HashSet as HS import qualified Text.Parsec as P import qualified Text.PrettyPrint.ANSI.Leijen as WL import qualified Text.Trifecta as T (eof, parseString)@@ -163,5 +164,9 @@ return $ MyInt3 42 , ediffGolden goldenTest "Positional" "fixtures/Positional.expr" $ return $ Positional 12 True 'z'++ -- issue #67+ , ediffGolden goldenTest "HashSet" "fixtures/HashSet.expr" $+ return $ HS.fromList [ [x,y] | x <- "abcd", y <- "xyz" ] ]
tree-diff.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: tree-diff-version: 0.2.2+version: 0.3 synopsis: Diffing of (expression) trees. category: Data, Testing description:@@ -85,22 +85,22 @@ -- GHC boot libraries build-depends:- , base >=4.5 && <4.18- , bytestring ^>=0.9.2.1 || ^>=0.10.0.2 || ^>=0.11.0.0- , containers ^>=0.4.2.1 || ^>=0.5.0.0 || ^>=0.6.0.1- , deepseq ^>=1.3.0.0 || ^>=1.4.0.0+ , base >=4.5 && <4.18+ , bytestring ^>=0.9.2.1 || ^>=0.10.0.2 || ^>=0.11.0.0+ , containers ^>=0.4.2.1 || ^>=0.5.0.0 || ^>=0.6.0.1+ , deepseq ^>=1.3.0.0 || ^>=1.4.0.0 , parsec ^>=3.1.13.0 , pretty ^>=1.1.1.0- , text ^>=1.2.3.0 || ^>=2.0- , time >=1.4 && <1.5 || >=1.5.0.1 && <1.6 || >=1.6.0.1 && <1.7 || >=1.8.0.2 && <1.9 || >=1.9.3 && <1.13+ , text ^>=1.2.3.0 || ^>=2.0+ , time >=1.4 && <1.5 || >=1.5.0.1 && <1.6 || >=1.6.0.1 && <1.7 || >=1.8.0.2 && <1.9 || >=1.9.3 && <1.13 build-depends:- , aeson ^>=1.4.6.0 || ^>=1.5.6.0 || ^>=2.0.0.0 || ^>=2.1.0.0- , ansi-terminal >=0.10 && <0.12+ , aeson ^>=1.4.6.0 || ^>=1.5.6.0 || ^>=2.0.0.0 || ^>=2.1.0.0+ , ansi-terminal >=0.10 && <0.12 , ansi-wl-pprint ^>=0.6.8.2- , base-compat >=0.10.5 && <0.11 || >=0.11.0 && <0.13+ , base-compat >=0.10.5 && <0.11 || >=0.11.0 && <0.13 , bytestring-builder ^>=0.10.8.2.0- , hashable ^>=1.2.7.0 || ^>=1.3.0.0 || ^>=1.4.0.1+ , hashable ^>=1.2.7.0 || ^>=1.3.0.0 || ^>=1.4.0.1 , parsers ^>=0.12.10 , primitive ^>=0.7.1.0 , QuickCheck ^>=2.14.2@@ -111,7 +111,7 @@ , these ^>=1.1.1.1 , unordered-containers ^>=0.2.8.0 , uuid-types ^>=1.0.3- , vector ^>=0.12.0.0 || ^>=0.13.0.0+ , vector ^>=0.12.0.0 || ^>=0.13.0.0 if impl(ghc <7.5) build-depends: ghc-prim@@ -128,6 +128,9 @@ , transformers ^>=0.3.0.0 || ^>=0.4.2.0 || ^>=0.5.2.0 , void ^>=0.7.3 + if impl(ghc >= 8) && !impl(ghc >=9.4)+ build-depends: data-array-byte >=0.1.0.1 && <0.2+ other-extensions: CPP ConstraintKinds@@ -160,16 +163,17 @@ , QuickCheck , tagged , tree-diff+ , unordered-containers if impl(ghc <7.5) build-depends: ghc-prim -- extra dependencies build-depends:- , tasty ^>=1.2 || ^>=1.3.1 || ^>=1.4.2+ , tasty ^>=1.2 || ^>=1.3.1 || ^>=1.4.2 , tasty-golden ^>=2.3.1.1 , tasty-quickcheck ^>=0.10.1- , trifecta >=2 && <2.2+ , trifecta >=2 && <2.2 benchmark tree-diff-bench default-language: Haskell2010