quickspec 0.9.4 → 0.9.5
raw patch · 3 files changed
+19/−33 lines, 3 filesdep −unordered-containers
Dependencies removed: unordered-containers
Files
- examples/Lists.hs +8/−8
- quickspec.cabal +2/−2
- src/Test/QuickSpec/Reasoning/UnionFind.hs +9/−23
examples/Lists.hs view
@@ -7,8 +7,8 @@ lists :: forall a. (Typeable a, Ord a, Arbitrary a, CoArbitrary a) => a -> [Sig] lists a = [- -- arith (undefined :: Int),- -- funs (undefined :: a),+ arith (undefined :: Int),+ funs (undefined :: a), ["x", "y", "z"] `vars` (undefined :: a), ["xs", "ys", "zs"] `vars` (undefined :: [a]),@@ -17,13 +17,13 @@ "[]" `fun0` ([] :: [a]), ":" `fun2` ((:) :: a -> [a] -> [a])], - -- "head" `fun1` (head :: [a] -> a),- -- "tail" `fun1` (tail :: [a] -> [a]),- -- "unit" `fun1` (return :: a -> [a]),+ "head" `fun1` (head :: [a] -> a),+ "tail" `fun1` (tail :: [a] -> [a]),+ "unit" `fun1` (return :: a -> [a]), "++" `fun2` ((++) :: [a] -> [a] -> [a]),- -- "length" `fun1` (length :: [a] -> Int),- "reverse" `fun1` (reverse :: [a] -> [a])- -- "map" `fun2` (map :: (a -> a) -> [a] -> [a])+ "length" `fun1` (length :: [a] -> Int),+ "reverse" `fun1` (reverse :: [a] -> [a]),+ "map" `fun2` (map :: (a -> a) -> [a] -> [a]) ] main = quickSpec (lists (undefined :: A))
quickspec.cabal view
@@ -1,5 +1,5 @@ Name: quickspec-Version: 0.9.4+Version: 0.9.5 Cabal-version: >=1.6 Build-type: Simple @@ -91,4 +91,4 @@ Build-depends: base < 5, containers, transformers, QuickCheck >= 2.7,- random, spoon >= 0.2, array, ghc-prim, mtl, unordered-containers+ random, spoon >= 0.2, array, ghc-prim, mtl
src/Test/QuickSpec/Reasoning/UnionFind.hs view
@@ -8,15 +8,10 @@ import Data.IntMap(IntMap) import qualified Data.IntMap as IntMap -data Info = Rep Int | NonRep Int--defaultInfo :: Info-defaultInfo = Rep 1- data S = S {- info :: IntMap Info,- sym :: Int- }+ links :: IntMap Int,+ sym :: Int+ } type UF = State S data Replacement = Int :> Int@@ -33,9 +28,9 @@ initial :: Int -> S initial n = S IntMap.empty n -modifyInfo f = modify (\s -> s { info = f (info s) })+modifyLinks f = modify (\s -> s { links = f (links s) }) modifySym f = modify (\s -> s { sym = f (sym s) })-putInfo i = modifyInfo (const i)+putLinks l = modifyLinks (const l) newSym :: UF Int newSym = do@@ -48,19 +43,10 @@ s =:= t = do rs <- rep s rt <- rep t- if (rs /= rt) then fmap Just (unifyRep rs rt) else return Nothing--unifyRep :: Int -> Int -> UF Replacement-unifyRep s t = do- ss <- gets (IntMap.findWithDefault 0 s . reps)- st <- gets (IntMap.findWithDefault 0 t . reps)- if ss <= st then replace s t ss st else replace t s st ss--replace :: Int -> Int -> Int -> Int -> UF Replacement-replace s t ss st = do- modifyReps (IntMap.delete s . IntMap.insert t (ss+st+1))- modifyLinks (IntMap.insert s t)- return (s :> t)+ if (rs /= rt) then do+ modifyLinks (IntMap.insert rs rt)+ return (Just (rs :> rt))+ else return Nothing rep :: Int -> UF Int rep t = do