Safe Haskell | Safe-Inferred |
---|
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 where
- class Monoid a where
- fromLaTeX :: LaTeXC l => LaTeX -> l
- liftL :: LaTeXC l => (LaTeX -> LaTeX) -> l -> l
- liftL2 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> l
- liftL3 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l
- comm0 :: LaTeXC l => String -> l
- commS :: LaTeXC l => String -> l
- braces :: LaTeXC l => l -> l
Documentation
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.
Minimal complete definition: mempty
and mappend
.
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 newtype
s and make those instances
of Monoid
, e.g. Sum
and Product
.
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.
Monoid Ordering | |
Monoid () | |
Monoid ByteString | |
Monoid Text | |
Monoid More | |
Monoid All | |
Monoid Any | |
Monoid Text | |
Monoid LaTeX | Method |
Monoid TeXCheck | |
Monoid [a] | |
Monoid a => Monoid (Maybe a) | Lift a semigroup into |
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 (Seq a) | |
Monoid b => Monoid (a -> b) | |
(Monoid a, Monoid b) => Monoid (a, b) | |
Monoid t => Monoid (Parser t a) | |
Monad m => Monoid (LaTeXT m a) | |
(Monoid a, Monoid b, Monoid c) => Monoid (a, b, c) | |
(Monoid a, Monoid b, Monoid c, Monoid d) => Monoid (a, b, c, d) | |
(Monoid a, Monoid b, Monoid c, Monoid d, Monoid e) => Monoid (a, b, c, d, e) |
Combinators
From LaTeX
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]
liftL2 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> lSource
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.
Others
comm0 :: LaTeXC l => String -> lSource
A simple (without arguments) and handy command generator using the name of the command.
comm0 str = fromLaTeX $ TeXComm str []