{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE TypeSynonymInstances #-}
module Text.Blaze.Front
(
Markup
, Tag
, Attribute
, AttributeValue
, dataAttribute
, customAttribute
, ToMarkup (..)
, unsafeByteString
, unsafeLazyByteString
, textTag
, stringTag
, ToValue (..)
, unsafeByteStringValue
, unsafeLazyByteStringValue
, (!)
, (!?)
, contents
) where
import Data.Int (Int32, Int64)
import Data.Word (Word32, Word64)
import Data.Text (Text)
import qualified Data.Text.Lazy as LT
import Prelude
import Text.Blaze.Front.Internal
class ToMarkup a where
toMarkup :: a -> Markup ev
preEscapedToMarkup :: a -> Markup ev
preEscapedToMarkup = a -> Markup ev
forall a ev. ToMarkup a => a -> Markup ev
toMarkup
{-# INLINE preEscapedToMarkup #-}
instance ToMarkup Text where
toMarkup :: Text -> Markup ev
toMarkup = Text -> Markup ev
forall ev. Text -> Markup ev
text
{-# INLINE toMarkup #-}
preEscapedToMarkup :: Text -> Markup ev
preEscapedToMarkup = Text -> Markup ev
forall ev. Text -> Markup ev
preEscapedText
{-# INLINE preEscapedToMarkup #-}
instance ToMarkup LT.Text where
toMarkup :: Text -> Markup ev
toMarkup = Text -> Markup ev
forall ev. Text -> Markup ev
lazyText
{-# INLINE toMarkup #-}
preEscapedToMarkup :: Text -> Markup ev
preEscapedToMarkup = Text -> Markup ev
forall ev. Text -> Markup ev
preEscapedLazyText
{-# INLINE preEscapedToMarkup #-}
instance ToMarkup String where
toMarkup :: String -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string
{-# INLINE toMarkup #-}
preEscapedToMarkup :: String -> Markup ev
preEscapedToMarkup = String -> Markup ev
forall ev. String -> Markup ev
preEscapedString
{-# INLINE preEscapedToMarkup #-}
instance ToMarkup Int where
toMarkup :: Int -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Int -> String) -> Int -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Int32 where
toMarkup :: Int32 -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Int32 -> String) -> Int32 -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Int64 where
toMarkup :: Int64 -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Int64 -> String) -> Int64 -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Char where
toMarkup :: Char -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Char -> String) -> Char -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall (m :: * -> *) a. Monad m => a -> m a
return
{-# INLINE toMarkup #-}
instance ToMarkup Bool where
toMarkup :: Bool -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Bool -> String) -> Bool -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Integer where
toMarkup :: Integer -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev)
-> (Integer -> String) -> Integer -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Float where
toMarkup :: Float -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Float -> String) -> Float -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Double where
toMarkup :: Double -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Double -> String) -> Double -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Word where
toMarkup :: Word -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Word -> String) -> Word -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Word32 where
toMarkup :: Word32 -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Word32 -> String) -> Word32 -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
instance ToMarkup Word64 where
toMarkup :: Word64 -> Markup ev
toMarkup = String -> Markup ev
forall ev. String -> Markup ev
string (String -> Markup ev) -> (Word64 -> String) -> Word64 -> Markup ev
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> String
forall a. Show a => a -> String
show
{-# INLINE toMarkup #-}
class ToValue a where
toValue :: a -> AttributeValue
preEscapedToValue :: a -> AttributeValue
preEscapedToValue = a -> AttributeValue
forall a. ToValue a => a -> AttributeValue
toValue
{-# INLINE preEscapedToValue #-}
instance ToValue AttributeValue where
toValue :: AttributeValue -> AttributeValue
toValue = AttributeValue -> AttributeValue
forall a. a -> a
id
{-# INLINE toValue #-}
instance ToValue Text where
toValue :: Text -> AttributeValue
toValue = Text -> AttributeValue
textValue
{-# INLINE toValue #-}
preEscapedToValue :: Text -> AttributeValue
preEscapedToValue = Text -> AttributeValue
preEscapedTextValue
{-# INLINE preEscapedToValue #-}
instance ToValue LT.Text where
toValue :: Text -> AttributeValue
toValue = Text -> AttributeValue
lazyTextValue
{-# INLINE toValue #-}
preEscapedToValue :: Text -> AttributeValue
preEscapedToValue = Text -> AttributeValue
preEscapedLazyTextValue
{-# INLINE preEscapedToValue #-}
instance ToValue String where
toValue :: String -> AttributeValue
toValue = String -> AttributeValue
stringValue
{-# INLINE toValue #-}
preEscapedToValue :: String -> AttributeValue
preEscapedToValue = String -> AttributeValue
preEscapedStringValue
{-# INLINE preEscapedToValue #-}
instance ToValue Int where
toValue :: Int -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Int -> String) -> Int -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Int32 where
toValue :: Int32 -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Int32 -> String) -> Int32 -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int32 -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Int64 where
toValue :: Int64 -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Int64 -> String) -> Int64 -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int64 -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Char where
toValue :: Char -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Char -> String) -> Char -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Char -> String
forall (m :: * -> *) a. Monad m => a -> m a
return
{-# INLINE toValue #-}
instance ToValue Bool where
toValue :: Bool -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Bool -> String) -> Bool -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Bool -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Integer where
toValue :: Integer -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Integer -> String) -> Integer -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Float where
toValue :: Float -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Float -> String) -> Float -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Float -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Double where
toValue :: Double -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Double -> String) -> Double -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Double -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Word where
toValue :: Word -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Word -> String) -> Word -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Word32 where
toValue :: Word32 -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Word32 -> String) -> Word32 -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}
instance ToValue Word64 where
toValue :: Word64 -> AttributeValue
toValue = String -> AttributeValue
stringValue (String -> AttributeValue)
-> (Word64 -> String) -> Word64 -> AttributeValue
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word64 -> String
forall a. Show a => a -> String
show
{-# INLINE toValue #-}