pomaps 0.2.0.0 → 0.2.0.1
raw patch · 3 files changed
+32/−9 lines, 3 filesdep ~basedep ~containersPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: base, containers
API changes (from Hackage documentation)
Files
- pomaps.cabal +5/−5
- src/Data/POMap/Internal.hs +3/−3
- tests/Data/POMap/Properties.hs +24/−1
pomaps.cabal view
@@ -1,5 +1,5 @@ name: pomaps-version: 0.2.0.0+version: 0.2.0.1 synopsis: Maps and sets of partial orders category: Data Structures homepage: https://github.com/sgraf812/pomaps#readme@@ -10,7 +10,7 @@ license-file: LICENSE.md build-type: Simple cabal-version: >= 1.10-tested-with: GHC ==8.8.1 || ==8.6.5 || ==8.4.4 || ==8.2.2+tested-with: GHC ==9.0.1 || ==8.10.2 || ==8.8.4 || ==8.6.5 || ==8.4.4 || ==8.2.2 extra-source-files: CHANGELOG.md@@ -34,15 +34,15 @@ src ghc-options: -Wall build-depends:- base >= 4.6.0.0 && < 4.14+ base >= 4.6.0.0 && < 4.15 -- oneShot- , ghc-prim >= 0.4 && < 0.6+ , ghc-prim >= 0.4 && < 0.7 , deepseq >= 1.1 && < 1.5 -- We depend on the internal modules of containers, -- so we have to track development really close. -- Data.Map.Internal is only available since 0.5.9, -- of which 0.5.9.2 is the first safe version- , containers >= 0.5.9.2 && <= 0.6.2.1+ , containers >= 0.5.9.2 && <= 0.6.4.1 -- We need PartialOrd instances for () , lattices >= 1.7 exposed-modules:
src/Data/POMap/Internal.hs view
@@ -577,7 +577,7 @@ case (k `leq` k', k' `leq` k) of (True, True) -> Found $ case f k (Just v') of Just v -> seq' s v (Bin n k' v l r)- Nothing -> Tip+ Nothing -> Map.link2 l r (True, False) -> oneShot (\l' -> Map.balanceL k' v' l' r) <$> go l (False, True) -> oneShot (\r' -> Map.balanceR k' v' l r') <$> go r (False, False) -> Incomparable@@ -615,7 +615,7 @@ case (k `leq` k', k' `leq` k) of (True, True) -> Found (Just v', case f k (Just v') of Just v -> seq' s v (Bin n k' v l r)- Nothing -> Tip)+ Nothing -> Map.link2 l r) (True, False) -> second (oneShot (\l' -> Map.balanceL k' v' l' r)) <$> go l (False, True) -> second (oneShot (\r' -> Map.balanceR k' v' l r')) <$> go r (False, False) -> Incomparable@@ -672,7 +672,7 @@ (True, True) -> ret Found (Just v) . oneShot $ \case Just v' -> seq' s v' (Bin n k v' l r)- Nothing -> Tip+ Nothing -> Map.link2 l r (True, False) -> lift (go l) . oneShot $ \l' -> Map.balanceL k' v l' r (False, True) -> lift (go r) . oneShot $ \r' -> Map.balanceL k' v l r' (False, False) -> Incomparable
tests/Data/POMap/Properties.hs view
@@ -1,7 +1,7 @@ {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TupleSections #-}-{-# OPTIONS_GHC -fno-warn-orphans #-}+{-# OPTIONS_GHC -O0 -fno-warn-orphans #-} module Data.POMap.Properties where import Algebra.PartialOrd@@ -21,6 +21,7 @@ import Data.POMap.Arbitrary () import Data.POMap.Divisibility import Data.POMap.Lazy+import qualified Data.POSet as POSet import Data.Traversable import Prelude hiding (filter, lookup, map, max, null) import Test.Tasty.Hspec@@ -58,6 +59,11 @@ isAntichain [] = True isAntichain (x:xs) = all (not . comparable x) xs && isAntichain xs +newtype OrdInt = OrdInt Int deriving (Eq, Show)+instance PartialOrd OrdInt where OrdInt sa `leq` OrdInt sb = sa <= sb+instance Arbitrary OrdInt where+ arbitrary = OrdInt <$> arbitrary+ spec :: Spec spec = describe "POMap" $ do@@ -549,3 +555,20 @@ fmap (+1) m `shouldBe` fmapDefault (+1) m it "foldMap = foldMapDefault" $ property $ \(m :: DivMap Int) -> foldMap Sum m `shouldBe` foldMapDefault Sum m++ describe "regression tests" $ do+ describe "#3" $ do+ it "example 1" $ do+ let e = OrdInt 13+ let s1 = POSet.delete e $+ POSet.fromList [ OrdInt 0, OrdInt 32, e ]+ let s2 = POSet.fromList [ OrdInt 0, OrdInt 32 ]+ s1 `shouldBe` s2+ length s1 `shouldBe` 2+ it "example 2" $ do+ let e = OrdInt 0+ let s1 = POSet.delete e $+ POSet.fromList [ e, OrdInt 1 ]+ let s2 = POSet.fromList [ OrdInt 1 ]+ s1 `shouldBe` s2+ length s1 `shouldBe` 1