Compat stuff for Monoid / Semigroup
This commit is contained in:
parent
96190a8ca4
commit
088637b2c0
1 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
|||
{-# LANGUAGE CPP #-}
|
||||
module PDF.Output (
|
||||
OBuilder(..)
|
||||
, Output(..)
|
||||
|
@ -13,6 +14,9 @@ module PDF.Output (
|
|||
|
||||
import Data.ByteString.Builder (Builder, char8, lazyByteString, string8, toLazyByteString)
|
||||
import Data.ByteString.Lazy.Char8 (ByteString)
|
||||
-- #if MIN_VERSION_base(4,9,0)
|
||||
-- import qualified Data.Semigroup as Sem
|
||||
-- #endif
|
||||
import Data.String (IsString(..))
|
||||
import Control.Monad.Reader (MonadReader(..), Reader, runReader)
|
||||
import qualified PDF.EOL as EOL (Style(..))
|
||||
|
@ -22,9 +26,19 @@ newtype OBuilder = OBuilder (Reader EOL.Style Builder)
|
|||
lift :: (a -> Builder) -> a -> OBuilder
|
||||
lift f a = OBuilder $ return (f a)
|
||||
|
||||
append :: OBuilder -> OBuilder -> OBuilder
|
||||
append (OBuilder a) (OBuilder b) = OBuilder (mappend <$> a <*> b)
|
||||
|
||||
#if MIN_VERSION_base(4,9,0)
|
||||
instance Semigroup OBuilder where
|
||||
(<>) = append
|
||||
#endif
|
||||
|
||||
instance Monoid OBuilder where
|
||||
mempty = OBuilder (return mempty)
|
||||
mappend (OBuilder a) (OBuilder b) = OBuilder (mappend <$> a <*> b)
|
||||
#if !(MIN_VERSION_base(4,9,0))
|
||||
mappend = append
|
||||
#endif
|
||||
|
||||
instance IsString OBuilder where
|
||||
fromString = string
|
||||
|
|
Loading…
Reference in a new issue