From cdfc5a078a334f8467fb52f30c3ef544b63be4d0 Mon Sep 17 00:00:00 2001 From: Johannes Gerer Date: Thu, 27 Oct 2016 02:46:07 +0200 Subject: fixed compilation error for GHC 7.6.3, 7.8.4, 7.10.3 --- src/Text/BlazeT/Internal.hs | 46 ++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'src/Text/BlazeT/Internal.hs') diff --git a/src/Text/BlazeT/Internal.hs b/src/Text/BlazeT/Internal.hs index aa56347..1a2fe8c 100644 --- a/src/Text/BlazeT/Internal.hs +++ b/src/Text/BlazeT/Internal.hs @@ -146,15 +146,15 @@ runMarkupT = runWriterT . fromMarkupT -- | run the MarkupT and return a pair consisting of the result of the -- computation and the blaze markup rendered with a blaze renderer -- like 'Text.BlazeT.Renderer.Text.renderHtml' -runWith :: Monad m => (Markup -> c) -> MarkupT m a -> m (a, c) -runWith renderer = liftM (second $ \x -> renderer $ wrapMarkup x) . runMarkupT +runWith :: Monad m => (MarkupI () -> c) -> MarkupT m a -> m (a, c) +runWith renderer = liftM (second $ renderer . wrapMarkup) . runMarkupT {-# INLINE runWith #-} execMarkupT :: Monad m => MarkupT m a -> m Text.Blaze.Markup execMarkupT = liftM snd . runMarkupT {-# INLINE execMarkupT #-} -execWith :: Monad m => (Markup -> c) -> MarkupT m a -> m c +execWith :: Monad m => (MarkupI () -> c) -> MarkupT m a -> m c execWith renderer = liftM snd . runWith renderer {-# INLINE execWith #-} @@ -166,26 +166,6 @@ execMarkup :: MarkupI a -> Text.Blaze.Markup execMarkup = snd . runMarkup {-# INLINE execMarkup #-} - -instance (Monad m,Monoid a) => Monoid (MarkupT m a) where - mempty = return mempty - {-# INLINE mempty #-} - a `mappend` b = do {a' <- a; b >>= return . (mappend a')} - {-# INLINE mappend #-} - - -instance Monad m => Text.Blaze.Attributable (MarkupT m a) where - h ! a = wrapMarkupT2 (Text.Blaze.! a) h - {-# INLINE (!) #-} - -instance Monad m => Text.Blaze.Attributable (a -> MarkupT m b) where - h ! a = \x -> wrapMarkupT2 (Text.Blaze.! a) $ h x - {-# INLINE (!) #-} - -instance Monad m => IsString (MarkupT m ()) where - fromString = wrapMarkup . fromString - {-# INLINE fromString #-} - -- | Wrapper for 'Text.Blaze.Markup' is simply -- 'tell' wrapMarkupT :: Monad m => Text.Blaze.Markup -> MarkupT m () @@ -208,6 +188,26 @@ wrapMarkup2 :: (Text.Blaze.Markup -> Text.Blaze.Markup) -> Markup2 wrapMarkup2 = wrapMarkupT2 {-# INLINE wrapMarkup2 #-} + +instance (Monad m,Monoid a) => Monoid (MarkupT m a) where + mempty = return mempty + {-# INLINE mempty #-} + a `mappend` b = do {a' <- a; b >>= return . (mappend a')} + {-# INLINE mappend #-} + + +instance Monad m => Text.Blaze.Attributable (MarkupT m a) where + h ! a = wrapMarkupT2 (Text.Blaze.! a) h + {-# INLINE (!) #-} + +instance Monad m => Text.Blaze.Attributable (a -> MarkupT m b) where + h ! a = \x -> wrapMarkupT2 (Text.Blaze.! a) $ h x + {-# INLINE (!) #-} + +instance Monad m => IsString (MarkupT m ()) where + fromString = wrapMarkup . fromString + {-# INLINE fromString #-} + unsafeByteString :: BS.ByteString -> Markup unsafeByteString = wrapMarkup . Text.Blaze.unsafeByteString {-# INLINE unsafeByteString #-} -- cgit v1.2.3