Module

Test.QuickCheck.Laws.Data

Package
purescript-quickcheck-laws
Repository
garyb/purescript-quickcheck-laws

Re-exports from Test.QuickCheck.Laws.Data.BooleanAlgebra

#checkBooleanAlgebra Source

checkBooleanAlgebra :: forall a eff. Arbitrary a => BooleanAlgebra a => Eq a => Proxy a -> QC eff Unit
  • Excluded middle: a || not a = tt

Re-exports from Test.QuickCheck.Laws.Data.Bounded

#checkBounded Source

checkBounded :: forall a eff. Arbitrary a => Bounded a => Ord a => Proxy a -> QC eff Unit
  • Ordering: bottom <= a <= top

Re-exports from Test.QuickCheck.Laws.Data.BoundedEnum

#checkBoundedEnum Source

checkBoundedEnum :: forall a eff. Arbitrary a => BoundedEnum a => Ord a => Proxy a -> QC eff Unit
  • succ: succ bottom >>= succ >>= succ ... succ [cardinality - 1 times] = top
  • pred: pred top >>= pred >>= pred ... pred [cardinality - 1 times] = bottom
  • predsucc: forall a > bottom: pred a >>= succ = Just a
  • succpred: forall a < top: succ a >>= pred = Just a
  • enumpred: forall a > bottom: fromEnum <$> pred a = Just (fromEnum a - 1)
  • enumsucc: forall a < top: fromEnum <$> succ a = Just (fromEnum a + 1)
  • compare: compare e1 e2 = compare (fromEnum e1) (fromEnum e2)
  • tofromenum: toEnum (fromEnum a) = Just a

Re-exports from Test.QuickCheck.Laws.Data.CommutativeRing

#checkCommutativeRing Source

checkCommutativeRing :: forall a eff. CommutativeRing a => Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Commutative multiplication: a * b = b * a

Re-exports from Test.QuickCheck.Laws.Data.Eq

#checkEq Source

checkEq :: forall a eff. Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Reflexivity: x == x = true
  • Symmetry: x == y = y == x
  • Transitivity: if x == y and y == z then x == z
  • Negation: x /= y = not (x == y)

Re-exports from Test.QuickCheck.Laws.Data.EuclideanRing

#checkEuclideanRing Source

checkEuclideanRing :: forall a eff. EuclideanRing a => Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Integral domain: a /= 0 and b /= 0 implies a * b /= 0
  • Multiplicative Euclidean function: a = (a / b) * b + (a `mod` b) where degree a > 0 and degree a <= degree (a * b)

Re-exports from Test.QuickCheck.Laws.Data.Field

#checkField Source

checkField :: forall a eff. Field a => Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Non-zero multiplicative inverse: `amodb = 0 for all a and b

Re-exports from Test.QuickCheck.Laws.Data.Foldable

#checkFoldableFunctor Source

checkFoldableFunctor :: forall f eff. Foldable f => Functor f => Arbitrary (f A) => Proxy2 f -> QC eff Unit

foldMap: foldMap = fold <<< map

#checkFoldable Source

checkFoldable :: forall f eff. Foldable f => Arbitrary (f A) => Proxy2 f -> QC eff Unit
  • foldr: foldr = foldrDefault
  • foldl: foldl = foldlDefault

Re-exports from Test.QuickCheck.Laws.Data.Functor

#checkFunctor Source

checkFunctor :: forall f eff. Functor f => Arbitrary (f A) => Eq (f A) => Proxy2 f -> QC eff Unit
  • Identity: (<$>) id = id
  • Composition: (<$>) (f <<< g) = (f <$>) <<< (g <$>)

Re-exports from Test.QuickCheck.Laws.Data.HeytingAlgebra

#checkHeytingAlgebra Source

checkHeytingAlgebra :: forall a eff. Arbitrary a => HeytingAlgebra a => Eq a => Proxy a -> QC eff Unit
  • Associativity:
    • a || (b || c) = (a || b) || c
    • a && (b && c) = (a && b) && c
  • Commutativity:
    • a || b = b || a
    • a && b = b && a
  • Absorption:
    • a || (a && b) = a
    • a && (a || b) = a
  • Idempotent:
    • a || a = a
    • a && a = a
  • Identity:
    • a || ff = a
    • a && tt = a
  • Implication:
    • a `implies` a = tt
    • a && (a `implies` b) = a && b
    • b && (a `implies` b) = b
    • a `implies` (b && c) = (a `implies` b) && (a `implies` c)
  • Complemented:
    • not a = a `implies` ff

Re-exports from Test.QuickCheck.Laws.Data.Monoid

#checkMonoid Source

checkMonoid :: forall m eff. Monoid m => Arbitrary m => Eq m => Proxy m -> QC eff Unit
  • Left identity: mempty <> x = x
  • Right identity: x <> mempty = x

Re-exports from Test.QuickCheck.Laws.Data.Ord

#checkOrd Source

checkOrd :: forall a eff. Arbitrary a => Ord a => Proxy a -> QC eff Unit
  • Reflexivity: a <= a
  • Antisymmetry: if a <= b and b <= a then a = b
  • Transitivity: if a <= b and b <= c then a <= c

Re-exports from Test.QuickCheck.Laws.Data.Ring

#checkRing Source

checkRing :: forall a eff. Ring a => Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Additive inverse: a - a = a + (-a) = (-a) + a = zero

Re-exports from Test.QuickCheck.Laws.Data.Semigroup

#checkSemigroup Source

checkSemigroup :: forall s eff. Semigroup s => Arbitrary s => Eq s => Proxy s -> QC eff Unit
  • Associativity: (x <> y) <> z = x <> (y <> z)

Re-exports from Test.QuickCheck.Laws.Data.Semiring

#checkSemiring Source

checkSemiring :: forall a eff. Semiring a => Arbitrary a => Eq a => Proxy a -> QC eff Unit
  • Commutative monoid under addition:
    • Associativity: (a + b) + c = a + (b + c)
    • Identity: zero + a = a + zero = a
    • Commutative: a + b = b + a
  • Monoid under multiplication:
    • Associativity: (a * b) * c = a * (b * c)
    • Identity: one * a = a * one = a
  • Multiplication distributes over addition:
    • Left distributivity: a * (b + c) = (a * b) + (a * c)
    • Right distributivity: (a + b) * c = (a * c) + (b * c)
  • Annihiliation: zero * a = a * zero = zero