git.iko.soy/typeable/pandoc
on master help sign in
Extensions: Semigroup instance for Extensions with base >= 4.9.
commit0cbb811f3d306f33299c2122c3ccc8f77642884c authorJohn MacFarlane <jgm@berkeley.edu> dateFri 16 Mar 2018, 08:20 (9 years ago) parent2240c4d
1 file changed+13−4
src/Text/Pandoc/Extensions.hs+13−4
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 #-}
16{-
27Copyright (C) 2012-2018 John MacFarlane <jgm@berkeley.edu>
38
@@ -15,10 +20,6 @@ You should have received a copy of the GNU General Public License
1520along with this program; if not, write to the Free Software
1621Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1722-}
18−{-# LANGUAGE DeriveDataTypeable #-}
19−{-# LANGUAGE DeriveGeneric #-}
20−{-# LANGUAGE GeneralizedNewtypeDeriving #-}
21−{-# LANGUAGE TemplateHaskell #-}
2223
2324{- |
2425 Module : Text.Pandoc.Extensions
@@ -59,9 +60,17 @@ import Text.Parsec
5960newtype Extensions = Extensions Integer
6061 deriving (Show, Read, Eq, Ord, Data, Typeable, Generic, ToJSON, FromJSON)
6162
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
6270instance Monoid Extensions where
6371 mempty = Extensions 0
6472 mappend (Extensions a) (Extensions b) = Extensions (a .|. b)
73+#endif
6574
6675extensionsFromList :: [Extension] -> Extensions
6776extensionsFromList = foldr enableExtension emptyExtensions