Safe Haskell | None |
---|---|
Language | Haskell2010 |
Documentation
class Convert a where Source #
Convert a type efficienctly to different string like types. 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 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 # | |
ConcatSymbol xs => Convert (Proxy [Symbol] xs) Source # | |
KnownSymbol a => Convert (Proxy Symbol a) Source # | |
Convert b => Convert ((:=) a b) Source # | |