aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJohannes Gerer <oss@johannesgerer.com>2016-10-27 02:38:57 +0200
committerJohannes Gerer <oss@johannesgerer.com>2016-10-27 02:38:57 +0200
commit73c84adf70ad57420416d0df9c8a328c6f690c18 (patch)
tree27c5a98ae9df9f5a5b2a58c612ca0b01e9223edc
parentfd25f72d8615ed8fd91317a6391e207a7aaba8d5 (diff)
downloadblazeT-temp.tar.gz
blazeT-temp.tar.zst
blazeT-temp.zip
-rw-r--r--src/Text/BlazeT/Internal.hs44
-rw-r--r--src/Text/BlazeT/Renderer/Pretty.hs4
-rw-r--r--src/Text/BlazeT/Renderer/String.hs4
-rw-r--r--src/Text/BlazeT/Renderer/Text.hs16
-rw-r--r--src/Text/BlazeT/Renderer/Utf8.hs14
5 files changed, 41 insertions, 41 deletions
diff --git a/src/Text/BlazeT/Internal.hs b/src/Text/BlazeT/Internal.hs
index aa56347..6e57b7c 100644
--- a/src/Text/BlazeT/Internal.hs
+++ b/src/Text/BlazeT/Internal.hs
@@ -146,7 +146,7 @@ runMarkupT = runWriterT . fromMarkupT
146-- | run the MarkupT and return a pair consisting of the result of the 146-- | run the MarkupT and return a pair consisting of the result of the
147-- computation and the blaze markup rendered with a blaze renderer 147-- computation and the blaze markup rendered with a blaze renderer
148-- like 'Text.BlazeT.Renderer.Text.renderHtml' 148-- like 'Text.BlazeT.Renderer.Text.renderHtml'
149runWith :: Monad m => (Markup -> c) -> MarkupT m a -> m (a, c) 149runWith :: Monad m => (MarkupI () -> c) -> MarkupT m a -> m (a, c)
150runWith renderer = liftM (second $ \x -> renderer $ wrapMarkup x) . runMarkupT 150runWith renderer = liftM (second $ \x -> renderer $ wrapMarkup x) . runMarkupT
151{-# INLINE runWith #-} 151{-# INLINE runWith #-}
152 152
@@ -154,7 +154,7 @@ execMarkupT :: Monad m => MarkupT m a -> m Text.Blaze.Markup
154execMarkupT = liftM snd . runMarkupT 154execMarkupT = liftM snd . runMarkupT
155{-# INLINE execMarkupT #-} 155{-# INLINE execMarkupT #-}
156 156
157execWith :: Monad m => (Markup -> c) -> MarkupT m a -> m c 157execWith :: Monad m => (MarkupI () -> c) -> MarkupT m a -> m c
158execWith renderer = liftM snd . runWith renderer 158execWith renderer = liftM snd . runWith renderer
159{-# INLINE execWith #-} 159{-# INLINE execWith #-}
160 160
@@ -166,26 +166,6 @@ execMarkup :: MarkupI a -> Text.Blaze.Markup
166execMarkup = snd . runMarkup 166execMarkup = snd . runMarkup
167{-# INLINE execMarkup #-} 167{-# INLINE execMarkup #-}
168 168
169
170instance (Monad m,Monoid a) => Monoid (MarkupT m a) where
171 mempty = return mempty
172 {-# INLINE mempty #-}
173 a `mappend` b = do {a' <- a; b >>= return . (mappend a')}
174 {-# INLINE mappend #-}
175
176
177instance Monad m => Text.Blaze.Attributable (MarkupT m a) where
178 h ! a = wrapMarkupT2 (Text.Blaze.! a) h
179 {-# INLINE (!) #-}
180
181instance Monad m => Text.Blaze.Attributable (a -> MarkupT m b) where
182 h ! a = \x -> wrapMarkupT2 (Text.Blaze.! a) $ h x
183 {-# INLINE (!) #-}
184
185instance Monad m => IsString (MarkupT m ()) where
186 fromString = wrapMarkup . fromString
187 {-# INLINE fromString #-}
188
189-- | Wrapper for 'Text.Blaze.Markup' is simply 169-- | Wrapper for 'Text.Blaze.Markup' is simply
190-- 'tell' 170-- 'tell'
191wrapMarkupT :: Monad m => Text.Blaze.Markup -> MarkupT m () 171wrapMarkupT :: Monad m => Text.Blaze.Markup -> MarkupT m ()
@@ -208,6 +188,26 @@ wrapMarkup2 :: (Text.Blaze.Markup -> Text.Blaze.Markup) -> Markup2
208wrapMarkup2 = wrapMarkupT2 188wrapMarkup2 = wrapMarkupT2
209{-# INLINE wrapMarkup2 #-} 189{-# INLINE wrapMarkup2 #-}
210 190
191
192instance (Monad m,Monoid a) => Monoid (MarkupT m a) where
193 mempty = return mempty
194 {-# INLINE mempty #-}
195 a `mappend` b = do {a' <- a; b >>= return . (mappend a')}
196 {-# INLINE mappend #-}
197
198
199instance Monad m => Text.Blaze.Attributable (MarkupT m a) where
200 h ! a = wrapMarkupT2 (Text.Blaze.! a) h
201 {-# INLINE (!) #-}
202
203instance Monad m => Text.Blaze.Attributable (a -> MarkupT m b) where
204 h ! a = \x -> wrapMarkupT2 (Text.Blaze.! a) $ h x
205 {-# INLINE (!) #-}
206
207instance Monad m => IsString (MarkupT m ()) where
208 fromString = wrapMarkup . fromString
209 {-# INLINE fromString #-}
210
211unsafeByteString :: BS.ByteString -> Markup 211unsafeByteString :: BS.ByteString -> Markup
212unsafeByteString = wrapMarkup . Text.Blaze.unsafeByteString 212unsafeByteString = wrapMarkup . Text.Blaze.unsafeByteString
213{-# INLINE unsafeByteString #-} 213{-# INLINE unsafeByteString #-}
diff --git a/src/Text/BlazeT/Renderer/Pretty.hs b/src/Text/BlazeT/Renderer/Pretty.hs
index 5e033ac..4fc77b7 100644
--- a/src/Text/BlazeT/Renderer/Pretty.hs
+++ b/src/Text/BlazeT/Renderer/Pretty.hs
@@ -7,9 +7,9 @@ module Text.BlazeT.Renderer.Pretty
7import qualified Text.Blaze.Renderer.Pretty as BU 7import qualified Text.Blaze.Renderer.Pretty as BU
8import Text.BlazeT 8import Text.BlazeT
9 9
10renderMarkup :: MarkupM a -> String 10renderMarkup :: MarkupI a -> String
11renderMarkup = BU.renderMarkup . execMarkup 11renderMarkup = BU.renderMarkup . execMarkup
12 12
13renderHtml :: MarkupM a -> String 13renderHtml :: MarkupI a -> String
14renderHtml = renderMarkup 14renderHtml = renderMarkup
15 15
diff --git a/src/Text/BlazeT/Renderer/String.hs b/src/Text/BlazeT/Renderer/String.hs
index 45c4786..615abbc 100644
--- a/src/Text/BlazeT/Renderer/String.hs
+++ b/src/Text/BlazeT/Renderer/String.hs
@@ -12,9 +12,9 @@ import Text.BlazeT
12fromChoiceString :: ChoiceString -> String -> String 12fromChoiceString :: ChoiceString -> String -> String
13fromChoiceString = BU.fromChoiceString 13fromChoiceString = BU.fromChoiceString
14 14
15renderMarkup :: MarkupM a -> String 15renderMarkup :: MarkupI a -> String
16renderMarkup = BU.renderMarkup . execMarkup 16renderMarkup = BU.renderMarkup . execMarkup
17 17
18renderHtml :: MarkupM a -> String 18renderHtml :: MarkupI a -> String
19renderHtml = renderMarkup 19renderHtml = renderMarkup
20 20
diff --git a/src/Text/BlazeT/Renderer/Text.hs b/src/Text/BlazeT/Renderer/Text.hs
index a595bd1..5e5583c 100644
--- a/src/Text/BlazeT/Renderer/Text.hs
+++ b/src/Text/BlazeT/Renderer/Text.hs
@@ -18,27 +18,27 @@ import qualified Text.Blaze.Html.Renderer.Text as BH
18import qualified Text.Blaze.Renderer.Text as BU 18import qualified Text.Blaze.Renderer.Text as BU
19import Text.BlazeT 19import Text.BlazeT
20 20
21renderMarkupBuilder :: MarkupM a -> B.Builder 21renderMarkupBuilder :: MarkupI a -> B.Builder
22renderMarkupBuilder = BU.renderMarkupBuilder . execMarkup 22renderMarkupBuilder = BU.renderMarkupBuilder . execMarkup
23 23
24renderHtmlBuilder :: MarkupM a -> B.Builder 24renderHtmlBuilder :: MarkupI a -> B.Builder
25renderHtmlBuilder = renderMarkupBuilder 25renderHtmlBuilder = renderMarkupBuilder
26 26
27renderMarkup :: MarkupM a -> L.Text 27renderMarkup :: MarkupI a -> L.Text
28renderMarkup = BU.renderMarkup . execMarkup 28renderMarkup = BU.renderMarkup . execMarkup
29 29
30renderHtml :: MarkupM a -> L.Text 30renderHtml :: MarkupI a -> L.Text
31renderHtml = renderMarkup 31renderHtml = renderMarkup
32 32
33renderMarkupWith :: (ByteString -> Text) -> MarkupM a -> L.Text 33renderMarkupWith :: (ByteString -> Text) -> MarkupI a -> L.Text
34renderMarkupWith g = (BH.renderHtmlWith g) . execMarkup 34renderMarkupWith g = (BH.renderHtmlWith g) . execMarkup
35 35
36renderHtmlWith :: (ByteString -> Text) -> MarkupM a -> L.Text 36renderHtmlWith :: (ByteString -> Text) -> MarkupI a -> L.Text
37renderHtmlWith = renderMarkupWith 37renderHtmlWith = renderMarkupWith
38 38
39renderMarkupBuilderWith :: (ByteString -> Text) -> MarkupM a -> B.Builder 39renderMarkupBuilderWith :: (ByteString -> Text) -> MarkupI a -> B.Builder
40renderMarkupBuilderWith g = (BU.renderMarkupBuilderWith g) . execMarkup 40renderMarkupBuilderWith g = (BU.renderMarkupBuilderWith g) . execMarkup
41 41
42renderHtmlBuilderWith :: (ByteString -> Text) -> MarkupM a -> B.Builder 42renderHtmlBuilderWith :: (ByteString -> Text) -> MarkupI a -> B.Builder
43renderHtmlBuilderWith = renderHtmlBuilderWith 43renderHtmlBuilderWith = renderHtmlBuilderWith
44 44
diff --git a/src/Text/BlazeT/Renderer/Utf8.hs b/src/Text/BlazeT/Renderer/Utf8.hs
index 6898e45..3862a2b 100644
--- a/src/Text/BlazeT/Renderer/Utf8.hs
+++ b/src/Text/BlazeT/Renderer/Utf8.hs
@@ -22,20 +22,20 @@ import qualified Data.ByteString.Lazy as BL
22import qualified Text.Blaze.Renderer.Utf8 as BU 22import qualified Text.Blaze.Renderer.Utf8 as BU
23import Text.BlazeT 23import Text.BlazeT
24 24
25renderMarkupBuilder :: MarkupM a -> B.Builder 25renderMarkupBuilder :: MarkupI a -> B.Builder
26renderMarkupBuilder x = BU.renderMarkupBuilder $ execMarkup x 26renderMarkupBuilder = BU.renderMarkupBuilder . execMarkup
27 27
28renderHtmlBuilder :: MarkupM a -> B.Builder 28renderHtmlBuilder :: MarkupI a -> B.Builder
29renderHtmlBuilder = renderMarkupBuilder 29renderHtmlBuilder = renderMarkupBuilder
30 30
31renderMarkup :: MarkupM a -> BL.ByteString 31renderMarkup :: MarkupI a -> BL.ByteString
32renderMarkup = BU.renderMarkup . execMarkup 32renderMarkup = BU.renderMarkup . execMarkup
33 33
34renderHtml :: MarkupM a -> BL.ByteString 34renderHtml :: MarkupI a -> BL.ByteString
35renderHtml = renderMarkup 35renderHtml = renderMarkup
36 36
37renderMarkupToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupM a -> IO () 37renderMarkupToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupI a -> IO ()
38renderMarkupToByteStringIO g = BU.renderMarkupToByteStringIO g . execMarkup 38renderMarkupToByteStringIO g = BU.renderMarkupToByteStringIO g . execMarkup
39 39
40renderHtmlToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupM a -> IO () 40renderHtmlToByteStringIO :: (BS.ByteString -> IO ()) -> MarkupI a -> IO ()
41renderHtmlToByteStringIO = renderMarkupToByteStringIO 41renderHtmlToByteStringIO = renderMarkupToByteStringIO