diff options
author | Christian Barcenas <christian@cbarcenas.com> | 2018-02-11 03:22:28 -0800 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2018-03-13 15:17:22 +0100 |
commit | 000627c94a4d4aedb0a4216e781f6af65936ef9c (patch) | |
tree | 5e450aa70633a37b3fda41cf8aa3d0c77379b790 /lib/Hakyll/Core/Rules | |
parent | 157fef58b97527b05b0400ad98d9cbdd2a33a0f4 (diff) | |
download | hakyll-000627c94a4d4aedb0a4216e781f6af65936ef9c.tar.gz |
Add Semigroup instances for existing Monoids
Ensures forwards compatibility with future Haskell/GHC releases
as the Semigroup/Monoid Proposal is gradually implemented.
Closes #525 and #536.
Diffstat (limited to 'lib/Hakyll/Core/Rules')
-rw-r--r-- | lib/Hakyll/Core/Rules/Internal.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Hakyll/Core/Rules/Internal.hs b/lib/Hakyll/Core/Rules/Internal.hs index 0641dcf..647af74 100644 --- a/lib/Hakyll/Core/Rules/Internal.hs +++ b/lib/Hakyll/Core/Rules/Internal.hs @@ -1,4 +1,5 @@ -------------------------------------------------------------------------------- +{-# LANGUAGE CPP #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE Rank2Types #-} module Hakyll.Core.Rules.Internal @@ -16,6 +17,9 @@ import Control.Monad.Reader (ask) import Control.Monad.RWS (RWST, runRWST) import Control.Monad.Trans (liftIO) import qualified Data.Map as M +#if MIN_VERSION_base(4,9,0) +import Data.Semigroup (Semigroup (..)) +#endif import Data.Set (Set) @@ -52,10 +56,20 @@ data RuleSet = RuleSet -------------------------------------------------------------------------------- +#if MIN_VERSION_base(4,9,0) +instance Semigroup RuleSet where + (<>) (RuleSet r1 c1 s1 p1) (RuleSet r2 c2 s2 p2) = + RuleSet (mappend r1 r2) (mappend c1 c2) (mappend s1 s2) (p1 .||. p2) + +instance Monoid RuleSet where + mempty = RuleSet mempty mempty mempty mempty + mappend = (<>) +#else instance Monoid RuleSet where mempty = RuleSet mempty mempty mempty mempty mappend (RuleSet r1 c1 s1 p1) (RuleSet r2 c2 s2 p2) = RuleSet (mappend r1 r2) (mappend c1 c2) (mappend s1 s2) (p1 .||. p2) +#endif -------------------------------------------------------------------------------- |