lattices 2.0.2 → 2.0.3
raw patch · 7 files changed
+82/−8 lines, 7 filesdep +OneTupledep ~basedep ~hashabledep ~semigroupsPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: OneTuple
Dependency ranges changed: base, hashable, semigroups, transformers
API changes (from Hackage documentation)
- Algebra.Heyting: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Universe.Class.Finite a) => Algebra.Heyting.Heyting (Data.HashSet.Base.HashSet a)
- Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => Algebra.Lattice.BoundedJoinSemiLattice (Data.HashSet.Base.HashSet a)
- Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => Algebra.Lattice.Lattice (Data.HashSet.Base.HashSet a)
- Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Universe.Class.Finite a) => Algebra.Lattice.BoundedMeetSemiLattice (Data.HashSet.Base.HashSet a)
- Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.Lattice.Lattice v) => Algebra.Lattice.BoundedJoinSemiLattice (Data.HashMap.Base.HashMap k v)
- Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.Lattice.Lattice v) => Algebra.Lattice.Lattice (Data.HashMap.Base.HashMap k v)
- Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Data.Universe.Class.Finite k, Algebra.Lattice.BoundedMeetSemiLattice v) => Algebra.Lattice.BoundedMeetSemiLattice (Data.HashMap.Base.HashMap k v)
- Algebra.PartialOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Algebra.PartialOrd.PartialOrd (Data.HashSet.Base.HashSet k)
- Algebra.PartialOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.PartialOrd.PartialOrd v) => Algebra.PartialOrd.PartialOrd (Data.HashMap.Base.HashMap k v)
+ Algebra.Heyting: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Universe.Class.Finite a) => Algebra.Heyting.Heyting (Data.HashSet.Internal.HashSet a)
+ Algebra.Heyting: instance Algebra.Heyting.Heyting a => Algebra.Heyting.Heyting (Data.Tuple.Solo.Solo a)
+ Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => Algebra.Lattice.BoundedJoinSemiLattice (Data.HashSet.Internal.HashSet a)
+ Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a) => Algebra.Lattice.Lattice (Data.HashSet.Internal.HashSet a)
+ Algebra.Lattice: instance (GHC.Classes.Eq a, Data.Hashable.Class.Hashable a, Data.Universe.Class.Finite a) => Algebra.Lattice.BoundedMeetSemiLattice (Data.HashSet.Internal.HashSet a)
+ Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.Lattice.Lattice v) => Algebra.Lattice.BoundedJoinSemiLattice (Data.HashMap.Internal.HashMap k v)
+ Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.Lattice.Lattice v) => Algebra.Lattice.Lattice (Data.HashMap.Internal.HashMap k v)
+ Algebra.Lattice: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Data.Universe.Class.Finite k, Algebra.Lattice.BoundedMeetSemiLattice v) => Algebra.Lattice.BoundedMeetSemiLattice (Data.HashMap.Internal.HashMap k v)
+ Algebra.Lattice: instance Algebra.Lattice.BoundedJoinSemiLattice a => Algebra.Lattice.BoundedJoinSemiLattice (Data.Tuple.Solo.Solo a)
+ Algebra.Lattice: instance Algebra.Lattice.BoundedMeetSemiLattice a => Algebra.Lattice.BoundedMeetSemiLattice (Data.Tuple.Solo.Solo a)
+ Algebra.Lattice: instance Algebra.Lattice.Lattice a => Algebra.Lattice.Lattice (Data.Tuple.Solo.Solo a)
+ Algebra.PartialOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k) => Algebra.PartialOrd.PartialOrd (Data.HashSet.Internal.HashSet k)
+ Algebra.PartialOrd: instance (GHC.Classes.Eq k, Data.Hashable.Class.Hashable k, Algebra.PartialOrd.PartialOrd v) => Algebra.PartialOrd.PartialOrd (Data.HashMap.Internal.HashMap k v)
Files
- CHANGELOG.md +4/−0
- lattices.cabal +15/−6
- src/Algebra/Heyting.hs +16/−1
- src/Algebra/Heyting/Free.hs +5/−0
- src/Algebra/Lattice.hs +27/−1
- src/Algebra/Lattice/Free.hs +3/−0
- test/Tests.hs +12/−0
CHANGELOG.md view
@@ -1,3 +1,7 @@+# 2.0.3 (2021-10-30)++- Add instances for `Solo`+ # 2.0.2 (2020-02-18) - Add `Algebra.Lattice.Stacked`
lattices.cabal view
@@ -1,6 +1,6 @@ cabal-version: 1.18 name: lattices-version: 2.0.2+version: 2.0.3 category: Math license: BSD3 license-file: LICENSE@@ -29,7 +29,10 @@ || ==8.2.2 || ==8.4.4 || ==8.6.5- || ==8.8.1+ || ==8.8.3+ || ==8.10.4+ || ==9.0.1+ || ==9.2.1 synopsis: Fine-grained library for constructing and manipulating lattices@@ -79,13 +82,13 @@ Algebra.PartialOrd.Instances build-depends:- base >=4.6 && <4.14- , base-compat >=0.10.5 && <0.12+ base >=4.6 && <4.17+ , base-compat >=0.10.5 && <0.13 , containers >=0.5.0.0 && <0.7 , deepseq >=1.3.0.0 && <1.5 , hashable >=1.2.7.0 && <1.4 , integer-logarithms >=1.0.3 && <1.1- , QuickCheck >=2.12.6.1 && <2.14+ , QuickCheck >=2.12.6.1 && <2.15 , semigroupoids >=5.3.2 && <5.4 , tagged >=0.8.6 && <0.9 , transformers >=0.3.0.0 && <0.6@@ -93,6 +96,12 @@ , universe-reverse-instances >=1.1 && <1.2 , unordered-containers >=0.2.8.0 && <0.3 + if !impl(ghc >=9.2)+ if impl(ghc >=9.0)+ build-depends: ghc-prim+ else+ build-depends: OneTuple >=0.3 && <0.4+ if !impl(ghc >=8.0) build-depends: semigroups >=0.18.5 && <0.20 @@ -115,7 +124,7 @@ , lattices , QuickCheck , quickcheck-instances >=0.3.19 && <0.4- , tasty >=1.2.1 && <1.3+ , tasty >=1.2.1 && <1.5 , tasty-quickcheck >=0.10 && <0.11 , transformers , universe-base
src/Algebra/Heyting.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE Safe #-} ----------------------------------------------------------------------------@@ -26,6 +27,14 @@ import qualified Data.HashSet as HS import qualified Data.Set as Set +#if MIN_VERSION_base(4,16,0)+import Data.Tuple (Solo (..))+#elif MIN_VERSION_base(4,15,0)+import GHC.Tuple (Solo (..))+#else+import Data.Tuple.Solo (Solo (..))+#endif+ -- | A Heyting algebra is a bounded lattice equipped with a -- binary operation \(a \to b\) of implication. --@@ -101,7 +110,7 @@ Endo a <=> Endo b = Endo (a <=> b) ---------------------------------------------------------------------------------- Proxy, Tagged, Const, Identity+-- Proxy, Tagged, Const, Identity, Solo ------------------------------------------------------------------------------- instance Heyting (Proxy a) where@@ -123,6 +132,12 @@ Const a ==> Const b = Const (a ==> b) neg (Const a) = Const (neg a) Const a <=> Const b = Const (a <=> b)++-- | @since 2.0.3+instance Heyting a => Heyting (Solo a) where+ Solo a ==> Solo b = Solo (a ==> b)+ neg (Solo a) = Solo (neg a)+ Solo a <=> Solo b = Solo (a <=> b) ------------------------------------------------------------------------------- -- Sets
src/Algebra/Heyting/Free.hs view
@@ -30,6 +30,11 @@ import qualified Algebra.Heyting.Free.Expr as E import qualified Test.QuickCheck as QC +-- $setup+-- >>> import Algebra.Lattice+-- >>> import Algebra.PartialOrd+-- >>> import Algebra.Heyting+ ------------------------------------------------------------------------------- -- Free -------------------------------------------------------------------------------
src/Algebra/Lattice.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric #-}@@ -65,6 +66,14 @@ import qualified Data.Set as Set import qualified Test.QuickCheck as QC +#if MIN_VERSION_base(4,16,0)+import Data.Tuple (Solo (..))+#elif MIN_VERSION_base(4,15,0)+import GHC.Tuple (Solo (..))+#else+import Data.Tuple.Solo (Solo (..))+#endif+ infixr 6 /\ -- This comment needed because of CPP infixr 5 \/ @@ -81,7 +90,7 @@ -- x '/\' (y '/\' z) ≡ (x '/\' y) '/\' z -- @ ----- /Commputativity/+-- /Commutativity/ -- -- @ -- x '\/' y ≡ y '\/' x@@ -487,6 +496,23 @@ instance BoundedJoinSemiLattice QC.Property where bottom = QC.property False instance BoundedMeetSemiLattice QC.Property where top = QC.property True++-------------------------------------------------------------------------------+-- OneTuple+-------------------------------------------------------------------------------++-- | @since 2.0.3+instance Lattice a => Lattice (Solo a) where+ Solo a \/ Solo b = Solo (a \/ b)+ Solo a /\ Solo b = Solo (a /\ b)++-- | @since 2.0.3+instance BoundedMeetSemiLattice a => BoundedMeetSemiLattice (Solo a) where+ top = Solo top++-- | @since 2.0.3+instance BoundedJoinSemiLattice a => BoundedJoinSemiLattice (Solo a) where+ bottom = Solo bottom ------------------------------------------------------------------------------- -- Theorems
src/Algebra/Lattice/Free.hs view
@@ -29,6 +29,9 @@ import qualified Algebra.Heyting.Free.Expr as E import qualified Test.QuickCheck as QC +-- $setup+-- >>> import Algebra.Lattice+ ------------------------------------------------------------------------------- -- Free -------------------------------------------------------------------------------
test/Tests.hs view
@@ -181,6 +181,7 @@ apProp :: m (Fun Int Int) -> m Int -> Property apProp f x = (f' <*> x) === ap f' x where f' = apply <$> f+{-# NOINLINE monadLaws #-} ------------------------------------------------------------------------------- -- Partial ord laws@@ -235,6 +236,7 @@ agree True False = (=== LT) agree False True = (=== GT) agree False False = discard+{-# NOINLINE partialOrdLaws #-} ------------------------------------------------------------------------------- -- Lattice@@ -292,6 +294,7 @@ [ booleanLaws pr | b >= IsBoolean ] where name = show (typeOf (undefined :: a))+{-# NOINLINE allLatticeLaws #-} allLatticeLaws' :: forall a. (Eq a, Show a, Arbitrary a, Lattice a, PartialOrd a)@@ -369,6 +372,7 @@ comparableDef :: a -> a -> Property comparableDef x y = (leq x y || leq y x) === comparable x y+{-# NOINLINE latticeLaws #-} ------------------------------------------------------------------------------- -- Modular@@ -386,6 +390,7 @@ modularProp x y z = lhs === rhs where lhs = (y /\ (x \/ z)) \/ z rhs = (y \/ z) /\ (x \/ z)+{-# NOINLINE modularLaws #-} ------------------------------------------------------------------------------- -- Distributive@@ -409,6 +414,7 @@ distr2Prop x y z = lhs === rhs where lhs = x \/ (y /\ z) rhs = (x \/ y) /\ (x \/ z)+{-# NOINLINE distributiveLaws #-} ------------------------------------------------------------------------------- -- Bounded lattice laws@@ -444,6 +450,7 @@ annihilationRightProp x = lhs === rhs where lhs = x \/ top rhs = top+{-# NOINLINE boundedMeetLaws #-} boundedJoinLaws :: forall a. (Eq a, Show a, Arbitrary a, BoundedJoinSemiLattice a)@@ -475,6 +482,7 @@ annihilationRightProp x = lhs === rhs where lhs = x /\ bottom rhs = bottom+{-# NOINLINE boundedJoinLaws #-} ------------------------------------------------------------------------------- -- Heyting laws@@ -541,6 +549,7 @@ deMorganProp2weak x y = lhs === rhs where lhs = neg (x /\ y) rhs = neg (neg (neg x \/ neg y))+{-# NOINLINE heytingLaws #-} ------------------------------------------------------------------------------- -- De morgan@@ -558,6 +567,7 @@ deMorganProp2 x y = lhs === rhs where lhs = neg (x /\ y) rhs = neg x \/ neg y+{-# NOINLINE deMorganLaws #-} ------------------------------------------------------------------------------- -- Boolean laws@@ -584,6 +594,7 @@ dnProp x = lhs === rhs where lhs = neg (neg x) rhs = x+{-# NOINLINE booleanLaws #-} ------------------------------------------------------------------------------- -- Universe / Finite laws@@ -620,6 +631,7 @@ cardinalityProp :: Property cardinalityProp = cardinality === (Tagged (genericLength (universeF :: [a])) :: Tagged a Natural)+{-# NOINLINE finiteLaws #-} ------------------------------------------------------------------------------- -- Lexicographic M2 search