summaryrefslogtreecommitdiff
path: root/compiler/llvmGen
diff options
context:
space:
mode:
authorDavid Luposchainsky <dluposchainsky@gmail.com>2015-11-29 22:59:57 +0100
committerBen Gamari <ben@smart-cactus.org>2015-11-29 23:00:48 +0100
commit290def72f54db7969258b4541aaefc87b54ce448 (patch)
tree5843028d9666626e3becb897e21e8caa007fd8c2 /compiler/llvmGen
parentbcd55a94f234f5efa4bb4fd24429dafc79d93106 (diff)
downloadhaskell-290def72f54db7969258b4541aaefc87b54ce448.tar.gz
Implement warnings for Semigroups as parent of Monoid
This patch is similar to the AMP patch (#8004), which offered two functions: 1. Warn when an instance of a class has been given, but the type does not have a certain superclass instance 2. Warn when top-level definitions conflict with future Prelude names These warnings are issued as part of the new `-Wcompat` warning group. Reviewers: hvr, ekmett, austin, bgamari Reviewed By: hvr, ekmett, bgamari Subscribers: ekmett, thomie Differential Revision: https://phabricator.haskell.org/D1539 GHC Trac Issues: #11139
Diffstat (limited to 'compiler/llvmGen')
-rw-r--r--compiler/llvmGen/LlvmCodeGen/CodeGen.hs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
index fb79a9d973..539e2220b7 100644
--- a/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
+++ b/compiler/llvmGen/LlvmCodeGen/CodeGen.hs
@@ -38,6 +38,10 @@ import Control.Monad.Trans.Writer
#else
import Data.Monoid ( Monoid, mappend, mempty )
#endif
+#if __GLASGOW_HASKELL__ > 710
+import Data.Semigroup ( Semigroup )
+import qualified Data.Semigroup as Semigroup
+#endif
import Data.List ( nub )
import Data.Maybe ( catMaybes )
@@ -1840,6 +1844,12 @@ getTBAARegMeta = getTBAAMeta . getTBAA
-- | A more convenient way of accumulating LLVM statements and declarations.
data LlvmAccum = LlvmAccum LlvmStatements [LlvmCmmDecl]
+#if __GLASGOW_HASKELL__ > 710
+instance Semigroup LlvmAccum where
+ LlvmAccum stmtsA declsA <> LlvmAccum stmtsB declsB =
+ LlvmAccum (stmtsA Semigroup.<> stmtsB) (declsA Semigroup.<> declsB)
+#endif
+
instance Monoid LlvmAccum where
mempty = LlvmAccum nilOL []
LlvmAccum stmtsA declsA `mappend` LlvmAccum stmtsB declsB =