packages feed

lawz 0.0.1 → 0.1

raw patch · 17 files changed

+54/−54 lines, 17 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Test.Util: (<==>) :: Bool -> Bool -> Bool
- Test.Util: (==>) :: Bool -> Bool -> Bool
- Test.Util: iff :: Bool -> Bool -> Bool
- Test.Util: infixr 0 ==>
- Test.Util: infixr 1 <==>
- Test.Util: type Rel r = r -> r -> Bool
- Test.Util: xor :: Bool -> Bool -> Bool
- Test.Util: xor3 :: Bool -> Bool -> Bool -> Bool
+ Test.Logic: (<==>) :: Bool -> Bool -> Bool
+ Test.Logic: (==>) :: Bool -> Bool -> Bool
+ Test.Logic: iff :: Bool -> Bool -> Bool
+ Test.Logic: infixr 0 ==>
+ Test.Logic: infixr 1 <==>
+ Test.Logic: type Rel r b = r -> r -> b
+ Test.Logic: xor :: Bool -> Bool -> Bool
+ Test.Logic: xor3 :: Bool -> Bool -> Bool -> Bool
- Test.Function.Equivalent: equivalent_on :: Rel r -> (r -> r) -> (r -> r) -> r -> Bool
+ Test.Function.Equivalent: equivalent_on :: Rel r b -> (r -> r) -> (r -> r) -> r -> b
- Test.Function.Idempotent: idempotent_on :: Rel r -> (r -> r) -> r -> Bool
+ Test.Function.Idempotent: idempotent_on :: Rel r b -> (r -> r) -> r -> b
- Test.Function.Idempotent: projective_on :: Rel s -> (r -> s) -> (s -> s) -> r -> Bool
+ Test.Function.Idempotent: projective_on :: Rel s b -> (r -> s) -> (s -> s) -> r -> b
- Test.Function.Injective: injective_on :: Rel r -> (r -> r) -> r -> r -> Bool
+ Test.Function.Injective: injective_on :: Rel r Bool -> (r -> r) -> r -> r -> Bool
- Test.Function.Invertible: adjoint_on :: Rel r -> Rel s -> (s -> r) -> (r -> s) -> s -> r -> Bool
+ Test.Function.Invertible: adjoint_on :: Rel r Bool -> Rel s Bool -> (s -> r) -> (r -> s) -> s -> r -> Bool
- Test.Function.Invertible: invertible_on :: Rel s -> (s -> r) -> (r -> s) -> s -> Bool
+ Test.Function.Invertible: invertible_on :: Rel s b -> (s -> r) -> (r -> s) -> s -> b
- Test.Function.Monotone: antitone_on :: Rel r -> Rel s -> (r -> s) -> r -> r -> Bool
+ Test.Function.Monotone: antitone_on :: Rel r Bool -> Rel s Bool -> (r -> s) -> r -> r -> Bool
- Test.Function.Monotone: monotone_on :: Rel r -> Rel s -> (r -> s) -> r -> r -> Bool
+ Test.Function.Monotone: monotone_on :: Rel r Bool -> Rel s Bool -> (r -> s) -> r -> r -> Bool
- Test.Operation.Annihilative: annihilative_on :: Rel r -> (r -> r -> r) -> r -> r -> Bool
+ Test.Operation.Annihilative: annihilative_on :: Rel r b -> (r -> r -> r) -> r -> r -> b
- Test.Operation.Annihilative: annihilative_on' :: Rel r -> (r -> r -> r) -> r -> r -> Bool
+ Test.Operation.Annihilative: annihilative_on' :: Rel r b -> (r -> r -> r) -> r -> r -> b
- Test.Operation.Associative: associative_on :: Rel r -> (r -> r -> r) -> r -> r -> r -> Bool
+ Test.Operation.Associative: associative_on :: Rel r b -> (r -> r -> r) -> r -> r -> r -> b
- Test.Operation.Commutative: commutative_on :: Rel r -> (r -> r -> r) -> r -> r -> Bool
+ Test.Operation.Commutative: commutative_on :: Rel r b -> (r -> r -> r) -> r -> r -> b
- Test.Operation.Distributive: distributive_on :: Rel r -> (r -> r -> r) -> (r -> r -> r) -> r -> r -> r -> Bool
+ Test.Operation.Distributive: distributive_on :: Rel r b -> (r -> r -> r) -> (r -> r -> r) -> r -> r -> r -> b
- Test.Operation.Distributive: distributive_on' :: Rel r -> (r -> r -> r) -> (r -> r -> r) -> r -> r -> r -> Bool
+ Test.Operation.Distributive: distributive_on' :: Rel r b -> (r -> r -> r) -> (r -> r -> r) -> r -> r -> r -> b
- Test.Operation.Neutral: neutral_on :: Rel r -> (r -> r -> r) -> r -> r -> Bool
+ Test.Operation.Neutral: neutral_on :: Rel r b -> (r -> r -> r) -> r -> r -> b
- Test.Operation.Neutral: neutral_on' :: Rel r -> (r -> r -> r) -> r -> r -> Bool
+ Test.Operation.Neutral: neutral_on' :: Rel r b -> (r -> r -> r) -> r -> r -> b

Files

lawz.cabal view
@@ -1,5 +1,5 @@ name:                lawz-version:             0.0.1+version:             0.1 synopsis:            Common mathematical laws. description:         Library of predicates for property testing. homepage:            https://github.com/cmk/lawz@@ -31,7 +31,7 @@      Test.Operation.Commutative      Test.Operation.Distributive      Test.Operation.Neutral-     Test.Util+     Test.Logic    default-extensions:      FlexibleInstances
src/Test/Function/Equivalent.hs view
@@ -1,6 +1,6 @@ module Test.Function.Equivalent where -import Test.Util+import Test.Logic   @@ -12,5 +12,5 @@  -- | \( \forall a: f a \doteq g a \) ---equivalent_on :: Rel r -> (r -> r) -> (r -> r) -> (r -> Bool)+equivalent_on :: Rel r b -> (r -> r) -> (r -> r) -> (r -> b) equivalent_on (~~) f g a = f a ~~ g a
src/Test/Function/Idempotent.hs view
@@ -2,7 +2,7 @@  import Data.List (unfoldr) import Numeric.Natural (Natural(..))-import Test.Util+import Test.Logic  -- | \( \forall a: g \circ f (a) = f (a) \) --@@ -11,7 +11,7 @@  -- | \( \forall a: g \circ f (a) \sim f (a) \) ---projective_on :: Rel s -> (r -> s) -> (s -> s) -> r -> Bool+projective_on :: Rel s b -> (r -> s) -> (s -> s) -> r -> b projective_on (~~) f g r = g (f r) ~~ f r  -- | \( \forall a: f \circ f(a) = f(a) \)@@ -21,7 +21,7 @@  -- | \( \forall a: f \circ f(a) \sim f(a) \) ---idempotent_on :: Rel r -> (r -> r) -> r -> Bool+idempotent_on :: Rel r b -> (r -> r) -> r -> b idempotent_on (~~) f = projective_on (~~) f f  idempotent_k :: Eq r => Natural -> (r -> r) -> r -> Bool
src/Test/Function/Injective.hs view
@@ -1,6 +1,6 @@ module Test.Function.Injective where -import Test.Util+import Test.Logic  -- | \( \forall a: f a \equiv f b \Rightarrow a \equiv b \) --@@ -10,5 +10,5 @@  -- | \( \forall a: f a \doteq f b \Rightarrow a \doteq b \) ---injective_on :: Rel r -> (r -> r) -> r -> r -> Bool+injective_on :: Rel r Bool -> (r -> r) -> r -> r -> Bool injective_on (~~) f a b = (f a ~~ f b) ==> (a ~~ b)
src/Test/Function/Invertible.hs view
@@ -1,13 +1,13 @@ module Test.Function.Invertible where -import Test.Util+import Test.Logic   -- | \( \forall a: f a \# b \Leftrightarrow a \# g b \) -- -- For example, a Galois connection is defined by @adjoint_on (<=)@. ---adjoint_on :: Rel r -> Rel s -> (s -> r) -> (r -> s) -> (s -> r -> Bool)+adjoint_on :: Rel r Bool -> Rel s Bool -> (s -> r) -> (r -> s) -> (s -> r -> Bool) adjoint_on (#) (%) f g a b = f a # b <==> a % g b  -- | \( \forall a: f (g a) \equiv a \)@@ -17,5 +17,5 @@  -- | \( \forall a: f (g a) \doteq a \) ---invertible_on :: Rel s -> (s -> r) -> (r -> s) -> (s -> Bool)+invertible_on :: Rel s b -> (s -> r) -> (r -> s) -> (s -> b) invertible_on (~~) f g a = g (f a) ~~ a
src/Test/Function/Monotone.hs view
@@ -1,13 +1,13 @@ module Test.Function.Monotone where -import Test.Util+import Test.Logic  monotone :: Ord r => (r -> r) -> r -> r -> Bool monotone = monotone_on (<=) (<=)  -- | \( \forall a, b: a \leq b \Rightarrow f(a) \leq f(b) \) ---monotone_on :: Rel r -> Rel s -> (r -> s) -> r -> r -> Bool+monotone_on :: Rel r Bool -> Rel s Bool -> (r -> s) -> r -> r -> Bool monotone_on (#) (%) f a b = a # b ==> f a % f b  antitone :: Ord r => (r -> r) -> r -> r -> Bool@@ -15,6 +15,6 @@  -- | \( \forall a, b: a \leq b \Rightarrow f(b) \leq f(a) \) ---antitone_on :: Rel r -> Rel s -> (r -> s) -> r -> r -> Bool+antitone_on :: Rel r Bool -> Rel s Bool -> (r -> s) -> r -> r -> Bool antitone_on (#) (%) f a b = a # b ==> f b % f a 
+ src/Test/Logic.hs view
@@ -0,0 +1,22 @@+module Test.Logic where++type Rel r b = r -> r -> b++xor :: Bool -> Bool -> Bool+xor a b = (a || b) && not (a && b)++xor3 :: Bool -> Bool -> Bool -> Bool+xor3 a b c = (a `xor` (b `xor` c)) && not (a && b && c)++infixr 0 ==>++(==>) :: Bool -> Bool -> Bool+(==>) a b = not a || b++iff :: Bool -> Bool -> Bool+iff a b = a ==> b && b ==> a++infixr 1 <==>++(<==>) :: Bool -> Bool -> Bool+(<==>) = iff
src/Test/Operation/Annihilative.hs view
@@ -1,6 +1,6 @@ module Test.Operation.Annihilative where -import Test.Util+import Test.Logic   -- | \( \forall a: (u \# a) \equiv u \)@@ -21,8 +21,8 @@ annihilative' :: Eq r => (r -> r -> r) -> r -> (r -> Bool) annihilative' = annihilative_on' (==) -annihilative_on :: Rel r -> (r -> r -> r) -> r -> (r -> Bool)+annihilative_on :: Rel r b -> (r -> r -> r) -> r -> (r -> b) annihilative_on (~~) (#) u a = (u # a) ~~ u -annihilative_on' :: Rel r -> (r -> r -> r) -> r -> (r -> Bool)+annihilative_on' :: Rel r b -> (r -> r -> r) -> r -> (r -> b) annihilative_on' (~~) (#) u a = (a # u) ~~ u
src/Test/Operation/Associative.hs view
@@ -1,6 +1,6 @@ module Test.Operation.Associative where -import Test.Util+import Test.Logic   -- | \( \forall a, b, c: (a \# b) \# c \equiv a \# (b \# c) \)@@ -11,5 +11,5 @@  -- | \( \forall a, b, c: (a \# b) \# c \doteq a \# (b \# c) \) ---associative_on :: Rel r -> (r -> r -> r) -> (r -> r -> r -> Bool)+associative_on :: Rel r b -> (r -> r -> r) -> (r -> r -> r -> b) associative_on (~~) (#) a b c = ((a # b) # c) ~~ (a # (b # c)) 
src/Test/Operation/Commutative.hs view
@@ -1,6 +1,6 @@ module Test.Operation.Commutative where -import Test.Util+import Test.Logic  -- | \( \forall a, b: a \# b \equiv b \# a \) --@@ -9,6 +9,6 @@  -- | \( \forall a, b: a \# b \doteq b \# a \) ---commutative_on :: Rel r -> (r -> r -> r) -> r -> r -> Bool+commutative_on :: Rel r b -> (r -> r -> r) -> r -> r -> b commutative_on (~~) (#) a b = (a # b) ~~ (b # a) 
src/Test/Operation/Distributive.hs view
@@ -1,6 +1,6 @@ module Test.Operation.Distributive where -import Test.Util+import Test.Logic   -- | \( \forall a, b, c: (a \# b) \% c \equiv (a \% c) \# (b \% c) \)@@ -13,8 +13,8 @@ distributive' :: Eq r => (r -> r -> r) -> (r -> r -> r) -> (r -> r -> r -> Bool) distributive' = distributive_on' (==) -distributive_on :: Rel r -> (r -> r -> r) -> (r -> r -> r) -> (r -> r -> r -> Bool)+distributive_on :: Rel r b -> (r -> r -> r) -> (r -> r -> r) -> (r -> r -> r -> b) distributive_on (~~) (#) (%) a b c = ((a # b) % c) ~~ ((a % c) # (b % c)) -distributive_on' :: Rel r -> (r -> r -> r) -> (r -> r -> r) -> (r -> r -> r -> Bool)+distributive_on' :: Rel r b -> (r -> r -> r) -> (r -> r -> r) -> (r -> r -> r -> b) distributive_on' (~~) (#) (%) a b c = (c % (a # b)) ~~ ((c % a) # (c % b))
src/Test/Operation/Neutral.hs view
@@ -1,6 +1,6 @@ module Test.Operation.Neutral where -import Test.Util+import Test.Logic  -- | \( \forall a: (u \# a) \equiv a \) --@@ -20,8 +20,8 @@ neutral' :: Eq r => (r -> r -> r) -> r -> (r -> Bool) neutral' = neutral_on' (==) -neutral_on :: Rel r -> (r -> r -> r) -> r -> (r -> Bool)+neutral_on :: Rel r b -> (r -> r -> r) -> r -> (r -> b) neutral_on (~~) (#) u a = (u # a) ~~ a -neutral_on' :: Rel r -> (r -> r -> r) -> r -> (r -> Bool)+neutral_on' :: Rel r b -> (r -> r -> r) -> r -> (r -> b) neutral_on' (~~) (#) u a = (a # u) ~~ a
src/Test/Relation/Connex.hs view
@@ -1,7 +1,7 @@ -- | See <https://en.wikipedia.org/wiki/Connex_relation>. module Test.Relation.Connex where -import Test.Util+import Test.Logic  -- | \( \forall a, b: ((a \# b) \vee (b \# a)) \) --
src/Test/Relation/Reflexive.hs view
@@ -9,7 +9,7 @@ --  The latter two facts also rule out quasi-reflexivity. module Test.Relation.Reflexive where -import Test.Util+import Test.Logic   -- | \( \forall a: (a \# a) \)
src/Test/Relation/Symmetric.hs view
@@ -6,7 +6,7 @@ -- \( a > 2 \) is neither symmetric nor antisymmetric, let alone asymmetric. module Test.Relation.Symmetric where -import Test.Util+import Test.Logic   -- | \( \forall a, b: (a \# b) \Leftrightarrow (b \# a) \)
src/Test/Relation/Transitive.hs view
@@ -1,6 +1,6 @@ module Test.Relation.Transitive where -import Test.Util+import Test.Logic   -- | \( \forall a, b, c: ((a \# b) \wedge (b \# c)) \Rightarrow (a \# c) \)
− src/Test/Util.hs
@@ -1,22 +0,0 @@-module Test.Util where--type Rel r = r -> r -> Bool--xor :: Bool -> Bool -> Bool-xor a b = (a || b) && not (a && b)--xor3 :: Bool -> Bool -> Bool -> Bool-xor3 a b c = (a `xor` (b `xor` c)) && not (a && b && c)--infixr 0 ==>--(==>) :: Bool -> Bool -> Bool-(==>) a b = not a || b--iff :: Bool -> Bool -> Bool-iff a b = a ==> b && b ==> a--infixr 1 <==>--(<==>) :: Bool -> Bool -> Bool-(<==>) = iff