aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers/Odt/StyleReader.hs
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-03-16 08:17:59 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-03-16 08:17:59 -0700
commit2240c4d80b15d45b8aa4683190748fcde50eb405 (patch)
tree0abf11c56333b9ec059e9498a35eb3385c2eb26a /src/Text/Pandoc/Readers/Odt/StyleReader.hs
parent94d64a63f2fb463bc260cf2f0bae1eff2116ce28 (diff)
downloadpandoc-2240c4d80b15d45b8aa4683190748fcde50eb405.tar.gz
Semigroup instance for Styles in T.P.Readers.Odt.StyleReader.
Diffstat (limited to 'src/Text/Pandoc/Readers/Odt/StyleReader.hs')
-rw-r--r--src/Text/Pandoc/Readers/Odt/StyleReader.hs14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/Odt/StyleReader.hs b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
index 58be8e4a3..1863773cf 100644
--- a/src/Text/Pandoc/Readers/Odt/StyleReader.hs
+++ b/src/Text/Pandoc/Readers/Odt/StyleReader.hs
@@ -1,5 +1,5 @@
+{-# LANGUAGE CPP #-}
{-# LANGUAGE Arrows #-}
-
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TupleSections #-}
@@ -80,7 +80,6 @@ import Text.Pandoc.Readers.Odt.Generic.XMLConverter
import Text.Pandoc.Readers.Odt.Base
import Text.Pandoc.Readers.Odt.Namespaces
-
readStylesAt :: XML.Element -> Fallible Styles
readStylesAt e = runConverter' readAllStyles mempty e
@@ -183,6 +182,16 @@ data Styles = Styles
deriving ( Show )
-- Styles from a monoid under union
+#if MIN_VERSION_base(4,9,0)
+instance Semigroup Styles where
+ (Styles sBn1 dSm1 lsBn1) <> (Styles sBn2 dSm2 lsBn2)
+ = Styles (M.union sBn1 sBn2)
+ (M.union dSm1 dSm2)
+ (M.union lsBn1 lsBn2)
+instance Monoid Styles where
+ mempty = Styles M.empty M.empty M.empty
+ mappend = (<>)
+#else
instance Monoid Styles where
mempty = Styles M.empty M.empty M.empty
mappend (Styles sBn1 dSm1 lsBn1)
@@ -190,6 +199,7 @@ instance Monoid Styles where
= Styles (M.union sBn1 sBn2)
(M.union dSm1 dSm2)
(M.union lsBn1 lsBn2)
+#endif
-- Not all families from the specifications are implemented, only those we need.
-- But there are none that are not mentioned here.