packages feed

svg-tree 0.6.2.1 → 0.6.2.2

raw patch · 3 files changed

+54/−38 lines, 3 filesdep +faildep +semigroupsdep ~base

Dependencies added: fail, semigroups

Dependency ranges changed: base

Files

changelog.md view
@@ -1,5 +1,9 @@ -*-change-log-*-
 
+v0.6.2.2 December 2017
+
+ * Adding `Semigroup` instances for defined `Monoid`, for GHC 8.4
+
 v0.6.2.1 December 2017
  * Workaround/Fix: removed reliance on Template Haskell to derive lenses,
    by writing them directly in the file, using the ddump-splices. For some
src/Graphics/Svg/Types.hs view
@@ -189,7 +189,8 @@ import Data.Function( on )
 import Data.List( inits )
 import qualified Data.Map as M
-import Data.Monoid( Last( .. ), (<>) )
+import Data.Semigroup( Semigroup( .. ) )
+import Data.Monoid( Last( .. ) )
 import qualified Data.Foldable as F
 import qualified Data.Text as T
 import Codec.Picture( PixelRGBA8( .. ) )
@@ -1314,15 +1315,18 @@   }
   deriving (Eq, Show)
 
-instance Monoid TextInfo where
-  mempty = TextInfo [] [] [] [] [] Nothing
-  mappend (TextInfo x1 y1 dx1 dy1 r1 l1)
-          (TextInfo x2 y2 dx2 dy2 r2 l2) =
+instance Semigroup TextInfo where
+  (<>) (TextInfo x1 y1 dx1 dy1 r1 l1)
+       (TextInfo x2 y2 dx2 dy2 r2 l2) =
     TextInfo (x1 <> x2)   (y1 <> y2)
                 (dx1 <> dx2) (dy1 <> dy2)
                 (r1 <> r2)
                 (getLast $ Last l1 <> Last l2)
 
+instance Monoid TextInfo where
+  mempty = TextInfo [] [] [] [] [] Nothing
+  mappend = (<>)
+
 -- makeClassy ''TextInfo
 -- | Lenses for the TextInfo type.
 class HasTextInfo c_ao0m where
@@ -2405,37 +2409,8 @@ mayMerge _ b@(Just _) = b
 mayMerge a Nothing = a
 
-instance Monoid DrawAttributes where
-    mempty = DrawAttributes
-        { _strokeWidth      = Last Nothing
-        , _strokeColor      = Last Nothing
-        , _strokeOpacity    = Nothing
-        , _strokeLineCap    = Last Nothing
-        , _strokeLineJoin   = Last Nothing
-        , _strokeMiterLimit = Last Nothing
-        , _fillColor        = Last Nothing
-        , _groupOpacity     = Nothing
-        , _fillOpacity      = Nothing
-        , _fontSize         = Last Nothing
-        , _fontFamily       = Last Nothing
-        , _fontStyle        = Last Nothing
-        , _transform        = Nothing
-        , _fillRule         = Last Nothing
-        , _attrClass        = mempty
-        , _attrId           = Nothing
-        , _strokeOffset     = Last Nothing
-        , _strokeDashArray  = Last Nothing
-        , _textAnchor       = Last Nothing
-        , _maskRef          = Last Nothing
-        , _clipPathRef      = Last Nothing
-        , _clipRule         = Last Nothing
-
-        , _markerStart      = Last Nothing
-        , _markerMid        = Last Nothing
-        , _markerEnd        = Last Nothing
-        }
-
-    mappend a b = DrawAttributes
+instance Semigroup DrawAttributes where
+  (<>) a b = DrawAttributes
         { _strokeWidth = (mappend `on` _strokeWidth) a b
         , _strokeColor =  (mappend `on` _strokeColor) a b
         , _strokeLineCap = (mappend `on` _strokeLineCap) a b
@@ -2467,6 +2442,37 @@         opacityMappend (Just v) Nothing = Just v
         opacityMappend Nothing (Just v) = Just v
         opacityMappend (Just v) (Just v2) = Just $ v * v2
+
+instance Monoid DrawAttributes where
+    mappend = (<>)
+    mempty = DrawAttributes
+        { _strokeWidth      = Last Nothing
+        , _strokeColor      = Last Nothing
+        , _strokeOpacity    = Nothing
+        , _strokeLineCap    = Last Nothing
+        , _strokeLineJoin   = Last Nothing
+        , _strokeMiterLimit = Last Nothing
+        , _fillColor        = Last Nothing
+        , _groupOpacity     = Nothing
+        , _fillOpacity      = Nothing
+        , _fontSize         = Last Nothing
+        , _fontFamily       = Last Nothing
+        , _fontStyle        = Last Nothing
+        , _transform        = Nothing
+        , _fillRule         = Last Nothing
+        , _attrClass        = mempty
+        , _attrId           = Nothing
+        , _strokeOffset     = Last Nothing
+        , _strokeDashArray  = Last Nothing
+        , _textAnchor       = Last Nothing
+        , _maskRef          = Last Nothing
+        , _clipPathRef      = Last Nothing
+        , _clipRule         = Last Nothing
+
+        , _markerStart      = Last Nothing
+        , _markerMid        = Last Nothing
+        , _markerEnd        = Last Nothing
+        }
 
 instance WithDefaultSvg DrawAttributes where
   defaultSvg = mempty
svg-tree.cabal view
@@ -1,5 +1,5 @@ name:                svg-tree
-version:             0.6.2.1
+version:             0.6.2.2
 synopsis:            SVG file loader and serializer
 description:
   svg-tree provides types representing a SVG document,
@@ -29,7 +29,7 @@ Source-Repository this
     Type:      git
     Location:  git://github.com/Twinside/svg-tree.git
-    Tag:       v0.6.2.1
+    Tag:       v0.6.2.2
 
 library
   hs-source-dirs: src
@@ -44,6 +44,12 @@                , Graphics.Svg.PathParser
                , Graphics.Svg.CssParser
                , Graphics.Svg.ColorParser
+
+  if impl(ghc >= 8.0)
+    ghc-options: -Wcompat -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances
+  else
+    -- provide/emulate `Control.Monad.Fail` and `Data.Semigroups` API for pre-GHC8
+    build-depends: fail == 4.9.*, semigroups == 0.18.*
 
   build-depends: base >= 4.5 && < 5
                , JuicyPixels >= 3.2