git.iko.soy/typeable/pandoc
on master help sign in
Extensions: Semigroup instance for Extensions with base >= 4.9.
0cbb811John MacFarlane
src/Text/Pandoc/Extensions.hs+13−4
@@ -1,3 +1,8 @@
1+{-# LANGUAGE CPP #-}
2+{-# LANGUAGE DeriveDataTypeable #-}
3+{-# LANGUAGE DeriveGeneric #-}
4+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
5+{-# LANGUAGE TemplateHaskell #-}
1{-
6{-
2Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
7Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
3
8
@@ -15,10 +20,6 @@ You should have received a copy of the GNU General Public License
15along with this program; if not, write to the Free Software
20along with this program; if not, write to the Free Software
16Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17-}
22-}
18−{-# LANGUAGE DeriveDataTypeable #-}
19−{-# LANGUAGE DeriveGeneric #-}
20−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
21−{-# LANGUAGE TemplateHaskell #-}
22
23
23{- |
24{- |
24 Module : Text.Pandoc.Extensions
25 Module : Text.Pandoc.Extensions
@@ -59,9 +60,17 @@ import Text.Parsec
59newtype Extensions = Extensions Integer
60newtype Extensions = Extensions Integer
60 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic, ToJSON, FromJSON)
61 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic, ToJSON, FromJSON)
61
62
63+#if MIN_VERSION_base(4,9,0)
64+instance Semigroup Extensions where
65+ (Extensions a) <> (Extensions b) = Extensions (a .|. b)
66+instance Monoid Extensions where
67+ mempty = Extensions 0
68+ mappend = (<>)
69+#else
62instance Monoid Extensions where
70instance Monoid Extensions where
63 mempty = Extensions 0
71 mempty = Extensions 0
64 mappend (Extensions a) (Extensions b) = Extensions (a .|. b)
72 mappend (Extensions a) (Extensions b) = Extensions (a .|. b)
73+#endif
65
74
66extensionsFromList :: [Extension] -> Extensions
75extensionsFromList :: [Extension] -> Extensions
67extensionsFromList = foldr enableExtension emptyExtensions
76extensionsFromList = foldr enableExtension emptyExtensions