abides 0.0.0 → 0.0.1
raw patch · 10 files changed
+91/−9 lines, 10 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
+ Test.Abides.Data.CommutativeRing: commutative :: Num a => Eq a => a -> a -> Bool
+ Test.Abides.Data.DivisionRing: inverse :: Fractional a => Eq a => a -> Bool
+ Test.Abides.Data.EuclideanRing: integralDomain :: Num a => Eq a => a -> a -> Bool
+ Test.Abides.Data.Ring: additiveInverse :: Num a => Eq a => a -> Bool
+ Test.Abides.Data.Semiring: annihilation :: Num a => Eq a => a -> Bool
+ Test.Abides.Data.Semiring: commutativeMonoid :: Num a => Eq a => a -> a -> a -> Bool
+ Test.Abides.Data.Semiring: leftDistributive :: Num a => Eq a => a -> a -> a -> Bool
+ Test.Abides.Data.Semiring: monoid :: Num a => Eq a => a -> a -> a -> Bool
+ Test.Abides.Data.Semiring: rightDistributive :: Num a => Eq a => a -> a -> a -> Bool
+ Test.Abides.Properties: distributive' :: Eq b => (a -> b) -> (a -> a -> a) -> (b -> b -> b) -> a -> a -> Bool
- Test.Abides.Control.Alternative: distributive :: Alternative f => Applicative f => Eq (f b) => f (a -> b) -> f (a -> b) -> f a -> Bool
+ Test.Abides.Control.Alternative: distributive :: Alternative f => Applicative f => Eq (f b) => f a -> f (a -> b) -> f (a -> b) -> Bool
Files
- abides.cabal +7/−3
- src/Test/Abides.hs +0/−2
- src/Test/Abides/Control/Alternative.hs +3/−2
- src/Test/Abides/Control/Monad.hs +2/−2
- src/Test/Abides/Data/CommutativeRing.hs +7/−0
- src/Test/Abides/Data/DivisionRing.hs +5/−0
- src/Test/Abides/Data/EuclideanRing.hs +26/−0
- src/Test/Abides/Data/Ring.hs +8/−0
- src/Test/Abides/Data/Semiring.hs +29/−0
- src/Test/Abides/Properties.hs +4/−0
abides.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: f1fefe867335372cccdb4d04ab5a2e0285abcc0e8080fbce2e12adf70dc571bd+-- hash: 242172040caaba3434259b2d0e15639272e8e6bf5a663a10cd009a6c82827125 name: abides-version: 0.0.0+version: 0.0.1 synopsis: Simple boolean tests to see if a value abides by certain properties description: Please see the README on GitHub at <https://github.com/athanclark/abides#readme> category: Data, Testing@@ -29,20 +29,24 @@ library exposed-modules:- Test.Abides Test.Abides.Control.Alternative Test.Abides.Control.Applicative Test.Abides.Control.Category Test.Abides.Control.Comonad Test.Abides.Control.Monad Test.Abides.Data.Bounded+ Test.Abides.Data.CommutativeRing+ Test.Abides.Data.DivisionRing Test.Abides.Data.Enum Test.Abides.Data.Eq+ Test.Abides.Data.EuclideanRing Test.Abides.Data.Foldable Test.Abides.Data.Functor Test.Abides.Data.Monoid Test.Abides.Data.Ord+ Test.Abides.Data.Ring Test.Abides.Data.Semigroup+ Test.Abides.Data.Semiring Test.Abides.Properties other-modules: Paths_abides
− src/Test/Abides.hs
@@ -1,2 +0,0 @@-module Test.Abides where-
src/Test/Abides/Control/Alternative.hs view
@@ -1,11 +1,12 @@ module Test.Abides.Control.Alternative where import Control.Applicative (Alternative ((<|>)), empty)+import qualified Test.Abides.Properties as P -- | (f <|> g) <*> x == (f <*> x) <|> (g <|> x)-distributive :: Alternative f => Applicative f => Eq (f b) => f (a -> b) -> f (a -> b) -> f a -> Bool-distributive f g x = ((f <|> g) <*> x) == ((f <*> x) <|> (g <*> x))+distributive :: Alternative f => Applicative f => Eq (f b) => f a -> f (a -> b) -> f (a -> b) -> Bool+distributive x = P.distributive' (<*> x) (<|>) (<|>) -- | empty <*> x == empty
src/Test/Abides/Control/Monad.hs view
@@ -1,7 +1,7 @@ module Test.Abides.Control.Monad where - import Control.Monad (MonadPlus (mzero, mplus))+import qualified Test.Abides.Properties as P leftIdentity :: Monad m => Eq (m b) => (a -> m b) -> a -> Bool@@ -21,4 +21,4 @@ distributive :: MonadPlus m => Eq (m b) => (a -> m b) -> m a -> m a -> Bool-distributive f x y = (mplus x y >>= f) == mplus (x >>= f) (y >>= f)+distributive f = P.distributive' (>>= f) mplus mplus
+ src/Test/Abides/Data/CommutativeRing.hs view
@@ -0,0 +1,7 @@+module Test.Abides.Data.CommutativeRing where++import qualified Test.Abides.Properties as P+++commutative :: Num a => Eq a => a -> a -> Bool+commutative = P.commutative (*)
+ src/Test/Abides/Data/DivisionRing.hs view
@@ -0,0 +1,5 @@+module Test.Abides.Data.DivisionRing where+++inverse :: Fractional a => Eq a => a -> Bool+inverse x = if x == 0 then True else (x * recip x) == (recip x * x) && (x * recip x) == 1
+ src/Test/Abides/Data/EuclideanRing.hs view
@@ -0,0 +1,26 @@+module Test.Abides.Data.EuclideanRing where+++integralDomain :: Num a => Eq a => a -> a -> Bool+integralDomain x y = if x /= 0 && y /= 0 then x * y /= 0 else True+++-- nonnegative :: Num a => Eq a => a -> Bool+-- nonnegative x = if x /= 0 then degree x >= 0 else True+++-- quotientRemainder :: Num a => Eq a => a -> a -> Bool+-- quotientRemainder x y =+-- if y /= 0+-- then+-- let q = x / y+-- r = x `mod` y+-- in (x == q * y + r) && ((r == 0) || (degree r < degree y))+-- else True+++-- submultiplicative :: Num a => Eq a => a -> a -> Bool+-- submultiplicative x y =+-- if x /= 0 && y /= 0+-- then degree x <= degree (x * y)+-- else True
+ src/Test/Abides/Data/Ring.hs view
@@ -0,0 +1,8 @@+module Test.Abides.Data.Ring where+++additiveInverse :: Num a => Eq a => a -> Bool+additiveInverse x = a && b+ where+ a = (x - x) == (x + negate x)+ b = (negate x + x) == 0
+ src/Test/Abides/Data/Semiring.hs view
@@ -0,0 +1,29 @@+module Test.Abides.Data.Semiring where++import qualified Test.Abides.Properties as P+++commutativeMonoid :: Num a => Eq a => a -> a -> a -> Bool+commutativeMonoid x y z = a && b && c+ where+ a = P.associative (+) x y z+ b = (0 + x == x + 0) && (x + 0 == x)+ c = P.commutative (+) x y+++monoid :: Num a => Eq a => a -> a -> a -> Bool+monoid x y z = a && b+ where+ a = P.associative (*) x y z+ b = (1 * x == x * 1) && (x * 1 == x)+++leftDistributive :: Num a => Eq a => a -> a -> a -> Bool+leftDistributive x = P.distributive (x *) (+)++rightDistributive :: Num a => Eq a => a -> a -> a -> Bool+rightDistributive x = P.distributive (* x) (+)+++annihilation :: Num a => Eq a => a -> Bool+annihilation x = (x * 0 == 0 * x) && (x * 0 == 0)
src/Test/Abides/Properties.hs view
@@ -21,6 +21,10 @@ distributive :: Eq a => (a -> a) -> (a -> a -> a) -> a -> a -> Bool distributive f g x y = f (g x y) == g (f x) (f y) +-- | f (g x y) == g' (f x) (f y)?+distributive' :: Eq b => (a -> b) -> (a -> a -> a) -> (b -> b -> b) -> a -> a -> Bool+distributive' f g g' x y = f (g x y) == g' (f x) (f y)+ -- | f x y == x? Note: bottom ~ forall y. f bottom y == bottom, while unit ~ forall x. f x unit == x constL :: Eq a => (a -> a -> a) -> a -> a -> Bool constL f x y = f x y == x