Extensions: Monoid instance for Extensions.

[API change]
This commit is contained in:
John MacFarlane 2017-06-24 13:20:30 +02:00
parent a20302d9cf
commit a9259c1501

View file

@ -45,7 +45,7 @@ module Text.Pandoc.Extensions ( Extension(..)
, githubMarkdownExtensions , githubMarkdownExtensions
, multimarkdownExtensions ) , multimarkdownExtensions )
where where
import Data.Bits (clearBit, setBit, testBit) import Data.Bits (clearBit, setBit, testBit, (.|.))
import Data.Data (Data) import Data.Data (Data)
import Data.Typeable (Typeable) import Data.Typeable (Typeable)
import GHC.Generics (Generic) import GHC.Generics (Generic)
@ -55,6 +55,10 @@ import Text.Parsec
newtype Extensions = Extensions Integer newtype Extensions = Extensions Integer
deriving (Show, Read, Eq, Ord, Data, Typeable, Generic) deriving (Show, Read, Eq, Ord, Data, Typeable, Generic)
instance Monoid Extensions where
mempty = Extensions 0
mappend (Extensions a) (Extensions b) = Extensions (a .|. b)
extensionsFromList :: [Extension] -> Extensions extensionsFromList :: [Extension] -> Extensions
extensionsFromList = foldr enableExtension emptyExtensions extensionsFromList = foldr enableExtension emptyExtensions