summaryrefslogtreecommitdiff
path: root/lib/Hakyll/Core/Compiler/Internal.hs
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/Compiler/Internal.hs
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/Compiler/Internal.hs')
-rw-r--r--lib/Hakyll/Core/Compiler/Internal.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/Hakyll/Core/Compiler/Internal.hs b/lib/Hakyll/Core/Compiler/Internal.hs
index 7b1df83..5b6d1aa 100644
--- a/lib/Hakyll/Core/Compiler/Internal.hs
+++ b/lib/Hakyll/Core/Compiler/Internal.hs
@@ -1,5 +1,6 @@
--------------------------------------------------------------------------------
-- | Internally used compiler module
+{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
@@ -32,6 +33,9 @@ import Control.Applicative (Alternative (..))
import Control.Exception (SomeException, handle)
import Control.Monad (forM_)
import Control.Monad.Except (MonadError (..))
+#if MIN_VERSION_base(4,9,0)
+import Data.Semigroup (Semigroup (..))
+#endif
import Data.Set (Set)
import qualified Data.Set as S
@@ -83,10 +87,20 @@ data CompilerWrite = CompilerWrite
--------------------------------------------------------------------------------
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup CompilerWrite where
+ (<>) (CompilerWrite d1 h1) (CompilerWrite d2 h2) =
+ CompilerWrite (d1 ++ d2) (h1 + h2)
+
+instance Monoid CompilerWrite where
+ mempty = CompilerWrite [] 0
+ mappend = (<>)
+#else
instance Monoid CompilerWrite where
mempty = CompilerWrite [] 0
mappend (CompilerWrite d1 h1) (CompilerWrite d2 h2) =
CompilerWrite (d1 ++ d2) (h1 + h2)
+#endif
--------------------------------------------------------------------------------