aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Text/BlazeT/Internal.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/BlazeT/Internal.hs')
-rw-r--r--src/Text/BlazeT/Internal.hs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Text/BlazeT/Internal.hs b/src/Text/BlazeT/Internal.hs
index 24ef1fe..f0c3edb 100644
--- a/src/Text/BlazeT/Internal.hs
+++ b/src/Text/BlazeT/Internal.hs
@@ -83,8 +83,11 @@ module Text.BlazeT.Internal
83 ,wrapMarkupT 83 ,wrapMarkupT
84 ,wrapMarkup2 84 ,wrapMarkup2
85 ,wrapMarkupT2 85 ,wrapMarkupT2
86 ,runWith
87 ,execWith
86 ) where 88 ) where
87 89
90import Control.Arrow
88import Control.Monad.Identity 91import Control.Monad.Identity
89import Control.Monad.Trans.Class 92import Control.Monad.Trans.Class
90import Control.Monad.Writer.Strict 93import Control.Monad.Writer.Strict
@@ -121,10 +124,21 @@ runMarkupT :: MarkupT m a -> m (a,B.Markup)
121runMarkupT = runWriterT . fromMarkupT 124runMarkupT = runWriterT . fromMarkupT
122{-# INLINE runMarkupT #-} 125{-# INLINE runMarkupT #-}
123 126
127-- | run the MarkupT and return a pair consisting of the result of the
128-- computation and the blaze markup rendered with a blaze renderer
129-- like 'Text.Blaze.Renderer.Text.renderHtml'
130runWith :: Monad m => (MarkupM () -> c) -> MarkupT m a -> m (a, c)
131runWith renderer = liftM (second $ renderer . wrapMarkup) . runMarkupT
132{-# INLINE runWith #-}
133
124execMarkupT :: Monad m => MarkupT m a -> m B.Markup 134execMarkupT :: Monad m => MarkupT m a -> m B.Markup
125execMarkupT = liftM snd . runMarkupT 135execMarkupT = liftM snd . runMarkupT
126{-# INLINE execMarkupT #-} 136{-# INLINE execMarkupT #-}
127 137
138execWith :: Monad m => (MarkupM () -> c) -> MarkupT m a -> m c
139execWith renderer = liftM snd . runWith renderer
140{-# INLINE execWith #-}
141
128runMarkup :: MarkupM a -> (a,B.Markup) 142runMarkup :: MarkupM a -> (a,B.Markup)
129runMarkup = runIdentity . runMarkupT 143runMarkup = runIdentity . runMarkupT
130{-# INLINE runMarkup #-} 144{-# INLINE runMarkup #-}