diff options
Diffstat (limited to 'src/Text/BlazeT/Internal.hs')
-rw-r--r-- | src/Text/BlazeT/Internal.hs | 14 |
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 | ||
90 | import Control.Arrow | ||
88 | import Control.Monad.Identity | 91 | import Control.Monad.Identity |
89 | import Control.Monad.Trans.Class | 92 | import Control.Monad.Trans.Class |
90 | import Control.Monad.Writer.Strict | 93 | import Control.Monad.Writer.Strict |
@@ -121,10 +124,21 @@ runMarkupT :: MarkupT m a -> m (a,B.Markup) | |||
121 | runMarkupT = runWriterT . fromMarkupT | 124 | runMarkupT = 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' | ||
130 | runWith :: Monad m => (MarkupM () -> c) -> MarkupT m a -> m (a, c) | ||
131 | runWith renderer = liftM (second $ renderer . wrapMarkup) . runMarkupT | ||
132 | {-# INLINE runWith #-} | ||
133 | |||
124 | execMarkupT :: Monad m => MarkupT m a -> m B.Markup | 134 | execMarkupT :: Monad m => MarkupT m a -> m B.Markup |
125 | execMarkupT = liftM snd . runMarkupT | 135 | execMarkupT = liftM snd . runMarkupT |
126 | {-# INLINE execMarkupT #-} | 136 | {-# INLINE execMarkupT #-} |
127 | 137 | ||
138 | execWith :: Monad m => (MarkupM () -> c) -> MarkupT m a -> m c | ||
139 | execWith renderer = liftM snd . runWith renderer | ||
140 | {-# INLINE execWith #-} | ||
141 | |||
128 | runMarkup :: MarkupM a -> (a,B.Markup) | 142 | runMarkup :: MarkupM a -> (a,B.Markup) |
129 | runMarkup = runIdentity . runMarkupT | 143 | runMarkup = runIdentity . runMarkupT |
130 | {-# INLINE runMarkup #-} | 144 | {-# INLINE runMarkup #-} |