git.iko.soy/typeable/pandoc
on master help sign in
Semigroup instance for Styles in T.P.Readers.Odt.StyleReader.
commit2240c4d80b15d45b8aa4683190748fcde50eb405 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 16 Mar 2018, 08:17 (9 years ago) parent94d64a6
1 file changed+12−2
src/Text/Pandoc/Readers/Odt/StyleReader.hs+12−2
src/Text/Pandoc/Readers/Odt/StyleReader.hs+12−2
@@ -1,5 +1,5 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE Arrows #-}
2−
33{-# LANGUAGE RecordWildCards #-}
44{-# LANGUAGE TupleSections #-}
55
@@ -80,7 +80,6 @@ import Text.Pandoc.Readers.Odt.Generic.XMLConverter
8080import Text.Pandoc.Readers.Odt.Base
8181import Text.Pandoc.Readers.Odt.Namespaces
8282
83−
8483readStylesAt :: XML.Element -> Fallible Styles
8584readStylesAt e = runConverter' readAllStyles mempty e
8685
@@ -183,6 +182,16 @@ data Styles = Styles
183182 deriving ( Show )
184183
185184-- Styles from a monoid under union
185+#if MIN_VERSION_base(4,9,0)
186+instance Semigroup Styles where
187+ (Styles sBn1 dSm1 lsBn1) <> (Styles sBn2 dSm2 lsBn2)
188+ = Styles (M.union sBn1 sBn2)
189+ (M.union dSm1 dSm2)
190+ (M.union lsBn1 lsBn2)
191+instance Monoid Styles where
192+ mempty = Styles M.empty M.empty M.empty
193+ mappend = (<>)
194+#else
186195instance Monoid Styles where
187196 mempty = Styles M.empty M.empty M.empty
188197 mappend (Styles sBn1 dSm1 lsBn1)
@@ -190,6 +199,7 @@ instance Monoid Styles where
190199 = Styles (M.union sBn1 sBn2)
191200 (M.union dSm1 dSm2)
192201 (M.union lsBn1 lsBn2)
202+#endif
193203
194204-- Not all families from the specifications are implemented, only those we need.
195205-- But there are none that are not mentioned here.