diff --git a/reflex.cabal b/reflex.cabal index 5e745176..c9aa2e4c 100644 --- a/reflex.cabal +++ b/reflex.cabal @@ -61,6 +61,11 @@ flag split-these manual: False default: True +flag commutative-semigroup + description: Use Data.Semigroup.Commutative instead of Data.Semigroup.Additive + manual: False + default: True + library default-language: Haskell2010 hs-source-dirs: src @@ -79,7 +84,6 @@ library mmorph >= 1.0 && < 1.2, monad-control >= 1.0.1 && < 1.1, mtl >= 2.1 && < 2.3, - patch >= 0.0.1 && < 0.1, prim-uniq >= 0.1.0.1 && < 0.3, primitive >= 0.5 && < 0.8, profunctors >= 5.3 && < 5.7, @@ -94,6 +98,14 @@ library unbounded-delays >= 0.1.0.0 && < 0.2, witherable >= 0.3 && < 0.4 + if flag(commutative-semigroup) + build-depends: + patch >= 0.0.7 && < 0.1, + commutative-semigroups >= 0 && < 0.2 + else + build-depends: + patch >= 0.0.1 && < 0.0.7 + if flag(split-these) build-depends: these >= 1 && <1.2, semialign >=1 && <1.2, diff --git a/src/Reflex/Query/Base.hs b/src/Reflex/Query/Base.hs index ec1ab548..7c20f89f 100644 --- a/src/Reflex/Query/Base.hs +++ b/src/Reflex/Query/Base.hs @@ -43,6 +43,7 @@ import Data.Monoid ((<>)) import qualified Data.Semigroup as S import Data.Some (Some(Some)) import Data.These +import Data.Semigroup.Additive import Reflex.Class import Reflex.Adjustable.Class diff --git a/src/Reflex/Query/Class.hs b/src/Reflex/Query/Class.hs index 794e72e7..e91be104 100644 --- a/src/Reflex/Query/Class.hs +++ b/src/Reflex/Query/Class.hs @@ -38,6 +38,10 @@ import qualified Data.Map.Monoidal as MonoidalMap import Data.Semigroup (Semigroup(..)) import Foreign.Storable import Data.Void +#if MIN_VERSION_patch(0,0,7) +import Data.Semigroup.Additive +import Data.Semigroup.Commutative +#endif import Data.Monoid hiding ((<>)) import Control.Applicative @@ -123,7 +127,11 @@ instance Monoid SelectedCount where instance Group SelectedCount where negateG (SelectedCount a) = SelectedCount (negate a) +#if MIN_VERSION_patch(0,0,7) +instance Commutative SelectedCount +#else instance Additive SelectedCount +#endif -- | The Semigroup\/Monoid\/Group instances for a Query containing 'SelectedCount's should use -- this function which returns Nothing if the result is 0. This allows the pruning of leaves