Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
class Convert a where Source #
Convert a type efficienctly to a renderable representation. Add instances if you want use custom types in your document.
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} module Main where import Html import Data.Text (Text) import Data.Monoid data Person = Person { name :: Text , age :: Int , vegetarian :: Bool } -- | This is already very efficient. -- Wrap the Strings in Raw if you don't want to escape them. instance Convert Person where convert (Person{..}) = convert name <> " is " <> convert age <> " years old and likes " <> if vegetarian then "oranges." else "meat." john :: Person john = Person {name = "John", age = 52, vegetarian = True} main :: IO () main = print (div_ john)
Convert Char Source # | |
Convert Double Source # | |
Convert Float Source # | |
Convert Int Source # | |
Convert Integer Source # | |
Convert Natural Source # | |
Convert Word Source # | |
Convert () Source # | |
Convert String Source # | |
Convert Text Source # | |
Convert Text Source # | |
Convert (Raw Char) Source # | |
Convert (Raw String) Source # | |
Convert (Raw Builder) Source # | |
Convert (Raw Text) Source # | |
Convert (Raw Text) Source # | |
KnownSymbol a => Convert (Proxy Symbol a) Source # | |