HaTeX-2.1.2: Text/LaTeX/Result.hs
{-# LANGUAGE OverloadedStrings #-}
module Text.LaTeX.Result (
-- * Result Type
Result
, toResult
, fromResult
-- * Special Characters
, resCharsStr
) where
import Data.Monoid
import Data.DString (DString)
import Data.String (fromString)
import Data.String.ToString (toString)
-- Result Type
--------------
-- Instances needed: Monoid, IsString, ToString
-- | The state of the @LaTeX@ monad. A 'Result' is represented by a 'DString'.
type Result = DString
--
-- | Transform a 'String' to a 'Result'.
toResult :: String -> Result
toResult = fromString
-- | Transform a 'Result' to a 'String'.
fromResult :: Result -> String
fromResult = toString
------------------------------------
-- | Set of LaTeX reserved characters, and their safe writings as 'Result's.
resCharsStr :: [(Char,Result)]
resCharsStr = [ ('#',"\\#")
, ('$',"\\$")
, ('%',"\\%")
, ('^',"\\^{}")
, ('&',"\\&")
, ('_',"\\_")
, ('{',"\\{")
, ('}',"\\}")
, ('~',"\\~{}")
, ('\\',"\\textbackslash{}") ]