[commit: packages/xhtml] master: Make xhtml -Wcompat clean by adding semigroup instances (8a8c8a4)

git at git.haskell.org git at git.haskell.org
Sat Jun 17 20:55:55 UTC 2017


Repository : ssh://git@git.haskell.org/xhtml

On branch  : master
Link       : http://git.haskell.org/packages/xhtml.git/commitdiff/8a8c8a48bac2d3ed306b610a2e9fa393b5a7ffa5

>---------------------------------------------------------------

commit 8a8c8a48bac2d3ed306b610a2e9fa393b5a7ffa5
Author: Herbert Valerio Riedel <hvr at gnu.org>
Date:   Tue Apr 18 12:05:38 2017 +0200

    Make xhtml -Wcompat clean by adding semigroup instances
    
    This also bumps xhtml's version to 3000.2.2, since the new instance
    represents a user-visible API addition.


>---------------------------------------------------------------

8a8c8a48bac2d3ed306b610a2e9fa393b5a7ffa5
 Text/XHtml/Internals.hs | 13 +++++++------
 xhtml.cabal             | 17 ++++++++++++++---
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/Text/XHtml/Internals.hs b/Text/XHtml/Internals.hs
index 7d5ac22..7de94d5 100644
--- a/Text/XHtml/Internals.hs
+++ b/Text/XHtml/Internals.hs
@@ -1,4 +1,3 @@
-{-# LANGUAGE CPP #-}
 {-# OPTIONS_HADDOCK hide #-}
 
 -----------------------------------------------------------------------------
@@ -17,9 +16,7 @@
 module Text.XHtml.Internals where
 
 import Data.Char
-#if __GLASGOW_HASKELL__ <= 708
-import Data.Monoid
-#endif
+import qualified Data.Semigroup as Sem
 
 infixr 2 +++  -- combining Html
 infixr 7 <<   -- nesting Html
@@ -66,9 +63,13 @@ instance Show HtmlAttr where
               showString "=" .
               shows val
 
-instance Monoid Html where
+-- | @since 3000.2.2
+instance Sem.Semigroup Html where
+    (<>) = (+++)
+
+instance Sem.Monoid Html where
     mempty = noHtml
-    mappend = (+++)
+    mappend = (Sem.<>)
 
 -- | HTML is the class of things that can be validly put
 -- inside an HTML tag. So this can be one or more 'Html' elements,
diff --git a/xhtml.cabal b/xhtml.cabal
index 6b7676e..104bc64 100644
--- a/xhtml.cabal
+++ b/xhtml.cabal
@@ -1,5 +1,5 @@
 Name:               xhtml
-Version:            3000.2.1
+Version:            3000.2.2
 Copyright:          Bjorn Bringert 2004-2006, Andy Gill and the Oregon
                     Graduate Institute of Science and Technology, 1999-2001
 Maintainer:         Chris Dornan <chris at chrisdornan.com>
@@ -23,11 +23,22 @@ Source-repository head
 
 library
     Default-Language: Haskell2010
-    Other-Extensions: CPP
     if impl(ghc >= 7.2)
         Default-Extensions: Safe
 
-    Build-depends:  base >= 4 && < 5
+    Build-depends: base >= 4 && < 5
+    if impl(ghc >= 8.0)
+        -- Enable warnings about potential future incompatibilities
+        ghc-options: -Wcompat -Wnoncanonical-monadfail-instances -Wnoncanonical-monad-instances
+    else
+        -- This provides compatibility with versions prior to GHC 8.0 / base-4.9, when `Data.Semigroup`
+        -- still lived in `semigroups`.
+
+        -- Note: semigroups-0.8 is a reasonably early version depending only on base & containers,
+        --       and `xhtml` only needs to define the class instance
+        --       so we can easily support a wide range of major
+        --       versions of `semigroups`
+        Build-depends: semigroups >= 0.8 && < 0.19
 
     Exposed-modules:
                     Text.XHtml,



More information about the ghc-commits mailing list