module Html
( renderString
, renderText
, renderByteString
, renderBuilder
, Document
, module Html.Type
, module Html.Convert
, module Html.Element
) where
import Html.Reify
import Html.Convert
import Html.Element
import Html.Type
import Html.Type.Internal
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString.Builder as B
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.Encoding as T
type Document a = Document' a
type Document' a = R (T (ToList a) a)
renderBuilder :: Document a => a -> B.Builder
renderBuilder = unConv . render . (T :: a -> T (ToList a) a)
renderString :: Document a => a -> String
renderString = T.unpack . renderText
renderText :: Document a => a -> T.Text
renderText = T.decodeUtf8 . renderByteString
renderByteString :: Document a => a -> B.ByteString
renderByteString = B.toLazyByteString . renderBuilder
instance Document ((a :@: b) c) => Show ((a :@: b) c) where show = renderString
instance Document ((a :@: b) c) => Show [(a :@: b) c] where show = renderString
instance Document (a := b) => Show (a := b) where show = renderString
instance Document (a # b) => Show (a # b) where show = renderString
instance Document (a # b) => Show [a # b] where show = renderString