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 (
|
module PDF.Output (
|
||||||
OBuilder(..)
|
OBuilder(..)
|
||||||
, Output(..)
|
, Output(..)
|
||||||
|
@ -13,6 +14,9 @@ module PDF.Output (
|
||||||
|
|
||||||
import Data.ByteString.Builder (Builder, char8, lazyByteString, string8, toLazyByteString)
|
import Data.ByteString.Builder (Builder, char8, lazyByteString, string8, toLazyByteString)
|
||||||
import Data.ByteString.Lazy.Char8 (ByteString)
|
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 Data.String (IsString(..))
|
||||||
import Control.Monad.Reader (MonadReader(..), Reader, runReader)
|
import Control.Monad.Reader (MonadReader(..), Reader, runReader)
|
||||||
import qualified PDF.EOL as EOL (Style(..))
|
import qualified PDF.EOL as EOL (Style(..))
|
||||||
|
@ -22,9 +26,19 @@ newtype OBuilder = OBuilder (Reader EOL.Style Builder)
|
||||||
lift :: (a -> Builder) -> a -> OBuilder
|
lift :: (a -> Builder) -> a -> OBuilder
|
||||||
lift f a = OBuilder $ return (f a)
|
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
|
instance Monoid OBuilder where
|
||||||
mempty = OBuilder (return mempty)
|
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
|
instance IsString OBuilder where
|
||||||
fromString = string
|
fromString = string
|
||||||
|
|
Loading…
Reference in a new issue