diff --git a/.gitignore b/.gitignore index 7001208..276e37b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ _darcs dist +dist-newstyle +.ghc.environment.* diff --git a/src/Data/Functor/Contravariant.hs b/src/Data/Functor/Contravariant.hs index 59f9986..8096afd 100644 --- a/src/Data/Functor/Contravariant.hs +++ b/src/Data/Functor/Contravariant.hs @@ -310,9 +310,18 @@ newtype Predicate a = Predicate { getPredicate :: a -> Bool } instance Contravariant Predicate where contramap f g = Predicate $ getPredicate g . f +#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 +instance Semigroup (Predicate a) where + Predicate p <> Predicate q = Predicate $ \a -> p a && q a +#endif + instance Monoid (Predicate a) where mempty = Predicate $ const True +#if defined(MIN_VERSION_semigroups) || __GLASGOW_HASKELL__ >= 711 + mappend = (<>) +#else mappend (Predicate p) (Predicate q) = Predicate $ \a -> p a && q a +#endif -- | Defines a total ordering on a type as per 'compare' --