HaTeX-3.17.3.0: The Haskell LaTeX library.

Safe HaskellSafe
LanguageHaskell2010

Text.LaTeX.Base.Class

Contents

Description

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.

Synopsis

Documentation

class (Monoid l, IsString l) => LaTeXC l where Source #

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

Minimal complete definition

liftListL

Methods

liftListL :: ([LaTeX] -> LaTeX) -> [l] -> l Source #

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.

Instances

LaTeXC LaTeX Source #

This instance just sets liftListL = id.

Methods

liftListL :: ([LaTeX] -> LaTeX) -> [LaTeX] -> LaTeX Source #

(Monad m, (~) * a ()) => LaTeXC (LaTeXT m a) Source # 

Methods

liftListL :: ([LaTeX] -> LaTeX) -> [LaTeXT m a] -> LaTeXT m a Source #

class Monoid a where #

The class of monoids (types with an associative binary operation that has an identity). Instances should satisfy the following laws:

  • mappend mempty x = x
  • mappend x mempty = x
  • mappend x (mappend y z) = mappend (mappend x y) z
  • mconcat = foldr mappend mempty

The method names refer to the monoid of lists under concatenation, but there are many other instances.

Some types can be viewed as a monoid in more than one way, e.g. both addition and multiplication on numbers. In such cases we often define newtypes and make those instances of Monoid, e.g. Sum and Product.

Minimal complete definition

mempty, mappend

Methods

mempty :: a #

Identity of mappend

mappend :: a -> a -> a #

An associative operation

mconcat :: [a] -> a #

Fold a list using the monoid. For most types, the default definition for mconcat will be used, but the function is included in the class definition so that an optimized version can be provided for specific types.

Instances

Monoid Ordering 
Monoid () 

Methods

mempty :: () #

mappend :: () -> () -> () #

mconcat :: [()] -> () #

Monoid All 

Methods

mempty :: All #

mappend :: All -> All -> All #

mconcat :: [All] -> All #

Monoid Any 

Methods

mempty :: Any #

mappend :: Any -> Any -> Any #

mconcat :: [Any] -> Any #

Monoid ByteString 
Monoid ByteString 
Monoid IntSet 
Monoid Doc 

Methods

mempty :: Doc #

mappend :: Doc -> Doc -> Doc #

mconcat :: [Doc] -> Doc #

Monoid LaTeX #

Method mappend is strict in both arguments (except in the case when the first argument is TeXEmpty).

Methods

mempty :: LaTeX #

mappend :: LaTeX -> LaTeX -> LaTeX #

mconcat :: [LaTeX] -> LaTeX #

Monoid TeXCheck # 
Monoid [a] 

Methods

mempty :: [a] #

mappend :: [a] -> [a] -> [a] #

mconcat :: [[a]] -> [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.

Methods

mempty :: Maybe a #

mappend :: Maybe a -> Maybe a -> Maybe a #

mconcat :: [Maybe a] -> Maybe a #

Monoid a => Monoid (IO a) 

Methods

mempty :: IO a #

mappend :: IO a -> IO a -> IO a #

mconcat :: [IO a] -> IO a #

Ord a => Monoid (Max a) 

Methods

mempty :: Max a #

mappend :: Max a -> Max a -> Max a #

mconcat :: [Max a] -> Max a #

Ord a => Monoid (Min a) 

Methods

mempty :: Min a #

mappend :: Min a -> Min a -> Min a #

mconcat :: [Min a] -> Min a #

Monoid a => Monoid (Identity a) 

Methods

mempty :: Identity a #

mappend :: Identity a -> Identity a -> Identity a #

mconcat :: [Identity a] -> Identity a #

(Ord a, Bounded a) => Monoid (Min a) 

Methods

mempty :: Min a #

mappend :: Min a -> Min a -> Min a #

mconcat :: [Min a] -> Min a #

(Ord a, Bounded a) => Monoid (Max a) 

Methods

mempty :: Max a #

mappend :: Max a -> Max a -> Max a #

mconcat :: [Max a] -> Max a #

Monoid m => Monoid (WrappedMonoid m) 
Semigroup a => Monoid (Option a) 

Methods

mempty :: Option a #

mappend :: Option a -> Option a -> Option a #

mconcat :: [Option a] -> Option a #

Monoid a => Monoid (Dual a) 

Methods

mempty :: Dual a #

mappend :: Dual a -> Dual a -> Dual a #

mconcat :: [Dual a] -> Dual a #

Monoid (Endo a) 

Methods

mempty :: Endo a #

mappend :: Endo a -> Endo a -> Endo a #

mconcat :: [Endo a] -> Endo a #

Num a => Monoid (Sum a) 

Methods

mempty :: Sum a #

mappend :: Sum a -> Sum a -> Sum a #

mconcat :: [Sum a] -> Sum a #

Num a => Monoid (Product a) 

Methods

mempty :: Product a #

mappend :: Product a -> Product a -> Product a #

mconcat :: [Product a] -> Product a #

Monoid (First a) 

Methods

mempty :: First a #

mappend :: First a -> First a -> First a #

mconcat :: [First a] -> First a #

Monoid (Last a) 

Methods

mempty :: Last a #

mappend :: Last a -> Last a -> Last a #

mconcat :: [Last a] -> Last a #

Monoid (IntMap a) 

Methods

mempty :: IntMap a #

mappend :: IntMap a -> IntMap a -> IntMap a #

mconcat :: [IntMap a] -> IntMap a #

Monoid (Seq a) 

Methods

mempty :: Seq a #

mappend :: Seq a -> Seq a -> Seq a #

mconcat :: [Seq a] -> Seq a #

Ord a => Monoid (Set a) 

Methods

mempty :: Set a #

mappend :: Set a -> Set a -> Set a #

mconcat :: [Set a] -> Set a #

Monoid (Vector a) 

Methods

mempty :: Vector a #

mappend :: Vector a -> Vector a -> Vector a #

mconcat :: [Vector a] -> Vector a #

Monoid a => Monoid (Matrix a) 

Methods

mempty :: Matrix a #

mappend :: Matrix a -> Matrix a -> Matrix a #

mconcat :: [Matrix a] -> Matrix a #

Monoid (Doc a) 

Methods

mempty :: Doc a #

mappend :: Doc a -> Doc a -> Doc a #

mconcat :: [Doc a] -> Doc a #

Monoid (Array a) 

Methods

mempty :: Array a #

mappend :: Array a -> Array a -> Array a #

mconcat :: [Array a] -> Array a #

Monoid (Doc e) 

Methods

mempty :: Doc e #

mappend :: Doc e -> Doc e -> Doc e #

mconcat :: [Doc e] -> Doc e #

Monoid b => Monoid (a -> b) 

Methods

mempty :: a -> b #

mappend :: (a -> b) -> (a -> b) -> a -> b #

mconcat :: [a -> b] -> a -> b #

(Monoid a, Monoid b) => Monoid (a, b) 

Methods

mempty :: (a, b) #

mappend :: (a, b) -> (a, b) -> (a, b) #

mconcat :: [(a, b)] -> (a, b) #

Monoid (Proxy k s) 

Methods

mempty :: Proxy k s #

mappend :: Proxy k s -> Proxy k s -> Proxy k s #

mconcat :: [Proxy k s] -> Proxy k s #

Ord k => Monoid (Map k v) 

Methods

mempty :: Map k v #

mappend :: Map k v -> Map k v -> Map k v #

mconcat :: [Map k v] -> Map k v #

(Monad m, Monoid a) => Monoid (LaTeXT m a) # 

Methods

mempty :: LaTeXT m a #

mappend :: LaTeXT m a -> LaTeXT m a -> LaTeXT m a #

mconcat :: [LaTeXT m a] -> LaTeXT m a #

(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) 

Methods

mempty :: (a, b, c) #

mappend :: (a, b, c) -> (a, b, c) -> (a, b, c) #

mconcat :: [(a, b, c)] -> (a, b, c) #

Monoid a => Monoid (Const k a b) 

Methods

mempty :: Const k a b #

mappend :: Const k a b -> Const k a b -> Const k a b #

mconcat :: [Const k a b] -> Const k a b #

Alternative f => Monoid (Alt * f a) 

Methods

mempty :: Alt * f a #

mappend :: Alt * f a -> Alt * f a -> Alt * f a #

mconcat :: [Alt * f a] -> Alt * f a #

(Semigroup a, Monoid a) => Monoid (Tagged k s a) 

Methods

mempty :: Tagged k s a #

mappend :: Tagged k s a -> Tagged k s a -> Tagged k s a #

mconcat :: [Tagged k s a] -> Tagged k s a #

(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) 

Methods

mempty :: (a, b, c, d) #

mappend :: (a, b, c, d) -> (a, b, c, d) -> (a, b, c, d) #

mconcat :: [(a, b, c, d)] -> (a, b, c, d) #

(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) 

Methods

mempty :: (a, b, c, d, e) #

mappend :: (a, b, c, d, e) -> (a, b, c, d, e) -> (a, b, c, d, e) #

mconcat :: [(a, b, c, d, e)] -> (a, b, c, d, e) #

Combinators

From LaTeX

fromLaTeX :: LaTeXC l => LaTeX -> l Source #

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

Lifting

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]

liftL :: LaTeXC l => (LaTeX -> LaTeX) -> l -> l Source #

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

liftL2 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> l Source #

Variant of liftL with a two arguments function.

liftL3 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l Source #

Variant of liftL with a three arguments function.

Others

comm0 :: LaTeXC l => String -> l Source #

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

comm0 str = fromLaTeX $ TeXComm str []

comm1 :: LaTeXC l => String -> l -> l Source #

A one parameter command generator using the name of the command. The parameter will be rendered as a fixed argument.

comm1 str = liftL $ \l -> TeXComm str [FixArg l]

comm2 :: LaTeXC l => String -> l -> l -> l Source #

A two parameter command generator using the name of the command. The parameters will be rendered as fixed arguments.

comm2 str = liftL2 $ \l1 l2 -> TeXComm str [FixArg l1, FixArg l2]

comm3 :: LaTeXC l => String -> l -> l -> l -> l Source #

A three parameter command generator using the name of the command. The parameters will be rendered as fixed arguments.

comm3 str = liftL2 $ \l1 l2 -> TeXComm str [FixArg l1, FixArg l2]

commS :: LaTeXC l => String -> l Source #

Like comm0 but using TeXCommS, i.e. no "{}" will be inserted to protect the command's end.

commS = fromLaTeX . TeXCommS

braces :: LaTeXC l => l -> l Source #

A lifted version of the TeXBraces constructor.

braces = liftL TeXBraces