summaryrefslogtreecommitdiff
path: root/lib/Hakyll/Core/Identifier
diff options
context:
space:
mode:
authorChristian Barcenas <christian@cbarcenas.com>2018-02-11 03:22:28 -0800
committerJasper Van der Jeugt <jaspervdj@gmail.com>2018-03-13 15:17:22 +0100
commit000627c94a4d4aedb0a4216e781f6af65936ef9c (patch)
tree5e450aa70633a37b3fda41cf8aa3d0c77379b790 /lib/Hakyll/Core/Identifier
parent157fef58b97527b05b0400ad98d9cbdd2a33a0f4 (diff)
downloadhakyll-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/Identifier')
-rw-r--r--lib/Hakyll/Core/Identifier/Pattern.hs13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Hakyll/Core/Identifier/Pattern.hs b/lib/Hakyll/Core/Identifier/Pattern.hs
index 83d5adc..a36e464 100644
--- a/lib/Hakyll/Core/Identifier/Pattern.hs
+++ b/lib/Hakyll/Core/Identifier/Pattern.hs
@@ -28,6 +28,7 @@
--
-- The 'capture' function allows the user to get access to the elements captured
-- by the capture elements in a glob or regex pattern.
+{-# LANGUAGE CPP #-}
module Hakyll.Core.Identifier.Pattern
( -- * The pattern type
Pattern
@@ -62,6 +63,9 @@ import Control.Monad (msum)
import Data.Binary (Binary (..), getWord8, putWord8)
import Data.List (inits, isPrefixOf, tails)
import Data.Maybe (isJust)
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup (..))
+#endif
import Data.Set (Set)
import qualified Data.Set as S
@@ -136,9 +140,18 @@ instance IsString Pattern where
--------------------------------------------------------------------------------
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup Pattern where
+ (<>) = (.&&.)
+
+instance Monoid Pattern where
+ mempty = Everything
+ mappend = (<>)
+#else
instance Monoid Pattern where
mempty = Everything
mappend = (.&&.)
+#endif
--------------------------------------------------------------------------------