HaTeX-3.5: The Haskell LaTeX library.

Safe HaskellNone




Definition of the LaTeXC class, used to combine the classic applicative and the latter monadic interfaces of HaTeX 3. The user can define new instances as well, adding flexibility to the way HaTeX is used.



class (Monoid l, IsString l) => LaTeXC l whereSource

This is the class of LaTeX code generators. It has Monoid and IsString as superclasses.



This method must take a function that combines a list of LaTeX values into a new one, and creates a function that combines l-typed values. The combining function can be seen as a function with 0 or more LaTeX arguments with a LaTeX value as output.



This instance just sets liftListL = id.

Monad m => LaTeXC (LaTeXT m a) 

class Monoid a where


  • mappend mempty x = x
  • mappend x mempty = x
  • mconcat = foldr mappend mempty


Minimal complete definition: mempty and mappend.



mempty :: a

Identity of mappend

mappend :: a -> a -> a

An associative operation

mconcat :: [a] -> a



Monoid Ordering 
Monoid () 
Monoid ByteString 
Monoid Text 
Monoid More 
Monoid All 
Monoid Any 
Monoid Text 
Monoid LaTeX


Monoid TeXCheck 
Monoid [a] 
Monoid a => Monoid (Maybe a)

Lift a semigroup into Maybe forming a Monoid according to http://en.wikipedia.org/wiki/Monoid: "Any semigroup S may be turned into a monoid simply by adjoining an element e not in S and defining e*e = e and e*s = s = s*e for all s ∈ S." Since there is no "Semigroup" typeclass providing just mappend, we use Monoid instead.

Monoid t => Monoid (Input t) 
Monoid t => Monoid (Added t) 
Monoid a => Monoid (Dual a) 
Monoid (Endo a) 
Num a => Monoid (Sum a) 
Num a => Monoid (Product a) 
Monoid (First a) 
Monoid (Last a) 
Monoid b => Monoid (a -> b) 
Monoid t => Monoid (Parser t a) 
Monad m => Monoid (LaTeXT m a)

mappend = >>.



From LaTeX

fromLaTeX :: LaTeXC l => LaTeX -> lSource

Map a LaTeX value to its equivalent in any LaTeXC instance.


Lifting functions from LaTeX functions to functions over any instance of LaTeXC. In general, the implementation is as follows:

 liftLN f x1 ... xN = liftListL (\[x1,...,xN] -> f x1 ... xN) [x1,...,xN]


Lift a inner function of LaTeX values into any LaTeXC instance.


Variant of liftL with a two arguments function.

liftL3 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> lSource

Variant of liftL with a three arguments function.


comm0 :: LaTeXC l => String -> lSource

A simple (without arguments) and handy command generator using the name of the command.

 comm0 str = fromLaTeX $ TeXComm str []

commS :: LaTeXC l => String -> lSource

Like comm0 but using commS.

 commS = fromLaTeX . TeXCommS

braces :: LaTeXC l => l -> lSource

A lifted version of the TeXBraces constructor.

 braces = liftL TeXBraces