{-# LANGUAGE FlexibleContexts      #-}
{-# LANGUAGE FlexibleInstances     #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeFamilies          #-}
{-# LANGUAGE UndecidableInstances  #-}

module IHP.HSX.ConvertibleStrings where

import Prelude
import Data.String.Conversions (ConvertibleStrings (convertString), cs)
import Text.Blaze.Html5
import Data.Text
import Data.ByteString
import qualified Text.Blaze.Html5        as Html5
import qualified Data.ByteString.Lazy as LBS

instance ConvertibleStrings String Html5.AttributeValue where
    {-# INLINE convertString #-}
    convertString :: String -> AttributeValue
convertString = String -> AttributeValue
stringValue

instance ConvertibleStrings Text Html5.AttributeValue where
    {-# INLINE convertString #-}
    convertString :: Text -> AttributeValue
convertString = Text -> AttributeValue
Html5.textValue

instance ConvertibleStrings String Html5.Html where
    {-# INLINE convertString #-}
    convertString :: String -> Html
convertString = String -> Html
Html5.string

instance ConvertibleStrings ByteString Html5.AttributeValue where
    {-# INLINE convertString #-}
    convertString :: ByteString -> AttributeValue
convertString ByteString
value = forall a b. ConvertibleStrings a b => a -> b
convertString (forall a b. ConvertibleStrings a b => a -> b
cs ByteString
value :: Text)

instance ConvertibleStrings LBS.ByteString Html5.AttributeValue where
    {-# INLINE convertString #-}
    convertString :: ByteString -> AttributeValue
convertString ByteString
value = forall a b. ConvertibleStrings a b => a -> b
convertString (forall a b. ConvertibleStrings a b => a -> b
cs ByteString
value :: Text)

instance ConvertibleStrings Text Html5.Html where
    {-# INLINE convertString #-}
    convertString :: Text -> Html
convertString = Text -> Html
Html5.text