{-# LANGUAGE CPP #-}
#if __GLASGOW_HASKELL__ >= 704
{-# OPTIONS_GHC -fsimpl-tick-factor=40000 #-}
#endif
module Blaze.ByteString.Builder.Html.Word
( wordHtmlEscaped
, writeHtmlEscapedWord
, fromHtmlEscapedWord
, fromHtmlEscapedWordList
, fromHtmlEscapedByteString
, fromHtmlEscapedLazyByteString
) where
import qualified Blaze.ByteString.Builder.Compat.Write as W
import qualified Data.ByteString as BS
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Builder.Prim as P
import Data.ByteString.Internal (c2w)
import qualified Data.ByteString.Lazy as BSL
import Data.Word (Word8)
{-# INLINE wordHtmlEscaped #-}
wordHtmlEscaped :: P.BoundedPrim Word8
wordHtmlEscaped :: BoundedPrim Word8
wordHtmlEscaped =
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Ord a => a -> a -> Bool
> Char -> Word8
c2w Char
'>' ) (forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\DEL') forall a. BoundedPrim a
P.emptyB forall a b. (a -> b) -> a -> b
$ forall a. FixedPrim a -> BoundedPrim a
P.liftFixedToBounded FixedPrim Word8
P.word8) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'<' ) (forall {a}. (Char, (Char, (Char, Char))) -> BoundedPrim a
fixed4 (Char
'&',(Char
'l',(Char
't',Char
';')))) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'>' ) (forall {a}. (Char, (Char, (Char, Char))) -> BoundedPrim a
fixed4 (Char
'&',(Char
'g',(Char
't',Char
';')))) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'&' ) (forall {a}. (Char, (Char, (Char, (Char, Char)))) -> BoundedPrim a
fixed5 (Char
'&',(Char
'a',(Char
'm',(Char
'p',Char
';'))))) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'"' ) (forall {a}.
(Char, (Char, (Char, (Char, (Char, Char))))) -> BoundedPrim a
fixed6 (Char
'&',(Char
'q',(Char
'u',(Char
'o',(Char
't',Char
';')))))) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\'') (forall {a}. (Char, (Char, (Char, (Char, Char)))) -> BoundedPrim a
fixed5 (Char
'&',(Char
'#',(Char
'3',(Char
'9',Char
';'))))) forall a b. (a -> b) -> a -> b
$
forall a.
(a -> Bool) -> BoundedPrim a -> BoundedPrim a -> BoundedPrim a
P.condB (\Word8
c -> Word8
c forall a. Ord a => a -> a -> Bool
>= Char -> Word8
c2w Char
' ' Bool -> Bool -> Bool
|| Word8
c forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\t' Bool -> Bool -> Bool
|| Word8
c forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\n' Bool -> Bool -> Bool
|| Word8
c forall a. Eq a => a -> a -> Bool
== Char -> Word8
c2w Char
'\r')
(forall a. FixedPrim a -> BoundedPrim a
P.liftFixedToBounded FixedPrim Word8
P.word8) forall a. BoundedPrim a
P.emptyB
where
{-# INLINE fixed4 #-}
fixed4 :: (Char, (Char, (Char, Char))) -> BoundedPrim a
fixed4 (Char, (Char, (Char, Char)))
x = forall a. FixedPrim a -> BoundedPrim a
P.liftFixedToBounded forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (Char, (Char, (Char, Char)))
x forall (f :: * -> *) b a. Contravariant f => (b -> a) -> f a -> f b
P.>$<
FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8
{-# INLINE fixed5 #-}
fixed5 :: (Char, (Char, (Char, (Char, Char)))) -> BoundedPrim a
fixed5 (Char, (Char, (Char, (Char, Char))))
x = forall a. FixedPrim a -> BoundedPrim a
P.liftFixedToBounded forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (Char, (Char, (Char, (Char, Char))))
x forall (f :: * -> *) b a. Contravariant f => (b -> a) -> f a -> f b
P.>$<
FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8
{-# INLINE fixed6 #-}
fixed6 :: (Char, (Char, (Char, (Char, (Char, Char))))) -> BoundedPrim a
fixed6 (Char, (Char, (Char, (Char, (Char, Char)))))
x = forall a. FixedPrim a -> BoundedPrim a
P.liftFixedToBounded forall a b. (a -> b) -> a -> b
$ forall a b. a -> b -> a
const (Char, (Char, (Char, (Char, (Char, Char)))))
x forall (f :: * -> *) b a. Contravariant f => (b -> a) -> f a -> f b
P.>$<
FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8 forall (f :: * -> *) a b. Monoidal f => f a -> f b -> f (a, b)
P.>*< FixedPrim Char
P.char8
writeHtmlEscapedWord :: Word8 -> W.Write
writeHtmlEscapedWord :: Word8 -> Write
writeHtmlEscapedWord = forall a. BoundedPrim a -> a -> Write
W.writePrimBounded BoundedPrim Word8
wordHtmlEscaped
fromHtmlEscapedWord :: Word8 -> B.Builder
fromHtmlEscapedWord :: Word8 -> Builder
fromHtmlEscapedWord = forall a. BoundedPrim a -> a -> Builder
P.primBounded BoundedPrim Word8
wordHtmlEscaped
fromHtmlEscapedWordList :: [Word8] -> B.Builder
fromHtmlEscapedWordList :: [Word8] -> Builder
fromHtmlEscapedWordList = forall a. BoundedPrim a -> [a] -> Builder
P.primMapListBounded BoundedPrim Word8
wordHtmlEscaped
fromHtmlEscapedByteString :: BS.ByteString -> B.Builder
fromHtmlEscapedByteString :: ByteString -> Builder
fromHtmlEscapedByteString = BoundedPrim Word8 -> ByteString -> Builder
P.primMapByteStringBounded BoundedPrim Word8
wordHtmlEscaped
fromHtmlEscapedLazyByteString :: BSL.ByteString -> B.Builder
fromHtmlEscapedLazyByteString :: ByteString -> Builder
fromHtmlEscapedLazyByteString = BoundedPrim Word8 -> ByteString -> Builder
P.primMapLazyByteStringBounded BoundedPrim Word8
wordHtmlEscaped