{-# LANGUAGE CPP #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}

-- | 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.
module Text.LaTeX.Base.Class (
   LaTeXC (..)
 , Monoid (..)
   -- * Combinators
   -- ** From @LaTeX@
 , fromLaTeX
   -- ** 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, liftL2, liftL3, liftL4, liftL5, liftL6, liftL7, liftL8, liftL9
   -- ** Others
 , comm0, comm1, comm2, comm3, comm4, comm5, comm6, comm7, comm8, comm9
 , commS
 , fixComm, optFixComm
 , env0, env1, env2, env3, env4, env5, env6, env7, env8, env9
 , fixEnv
 , braces, squareBraces
 , raw
 ) where

import Text.LaTeX.Base.Syntax
import Data.String
#if !MIN_VERSION_base(4,8,0)
import Data.Monoid
#endif
import Data.Text (Text)

-- | This is the class of 'LaTeX' code generators. It has 'Monoid' and 'IsString' as
--   superclasses.
class (Monoid l,IsString l) => LaTeXC l where
    -- | 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.
    liftListL :: ([LaTeX] -> LaTeX) -> [l] -> l

-- | This instance just sets @liftListL = id@.
instance LaTeXC LaTeX where
    liftListL :: ([LaTeX] -> LaTeX) -> [LaTeX] -> LaTeX
liftListL = forall a. a -> a
id

-- COMBINATORS

-- | Map a 'LaTeX' value to its equivalent in any 'LaTeXC' instance.
fromLaTeX :: LaTeXC l => LaTeX -> l
fromLaTeX :: forall l. LaTeXC l => LaTeX -> l
fromLaTeX LaTeX
l = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (forall a b. a -> b -> a
const LaTeX
l) []

-- | Lift a inner function of 'LaTeX' values into any 'LaTeXC' instance.
liftL :: LaTeXC l => (LaTeX -> LaTeX) -> l -> l
liftL :: forall l. LaTeXC l => (LaTeX -> LaTeX) -> l -> l
liftL LaTeX -> LaTeX
f l
x1 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1] -> LaTeX -> LaTeX
f LaTeX
x1) [l
x1]

-- | Variant of 'liftL' with a two arguments function.
liftL2 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> l
liftL2 :: forall l. LaTeXC l => (LaTeX -> LaTeX -> LaTeX) -> l -> l -> l
liftL2 LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2] -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2) [l
x1,l
x2]

-- | Variant of 'liftL' with a three arguments function.
liftL3 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l
liftL3 :: forall l.
LaTeXC l =>
(LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l
liftL3 LaTeX -> LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 l
x3 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3] -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3) [l
x1,l
x2,l
x3]

-- | Variant of 'liftL' with a four arguments function.
liftL4 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l
liftL4 :: forall l.
LaTeXC l =>
(LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX)
-> l -> l -> l -> l -> l
liftL4 LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 l
x3 l
x4 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4] -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4) [l
x1,l
x2,l
x3,l
x4]

-- | Variant of 'liftL' with a five arguments function.
liftL5 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l
liftL5 :: forall l.
LaTeXC l =>
(LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX)
-> l -> l -> l -> l -> l -> l
liftL5 LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 l
x3 l
x4 l
x5 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4,LaTeX
x5] -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4 LaTeX
x5) [l
x1,l
x2,l
x3,l
x4,l
x5]

-- | Variant of 'liftL' with a six arguments function.
liftL6 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l
liftL6 :: forall l.
LaTeXC l =>
(LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX)
-> l -> l -> l -> l -> l -> l -> l
liftL6 LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 l
x3 l
x4 l
x5 l
x6 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4,LaTeX
x5,LaTeX
x6] -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4 LaTeX
x5 LaTeX
x6) [l
x1,l
x2,l
x3,l
x4,l
x5,l
x6]

-- | Variant of 'liftL' with a seven arguments function.
liftL7 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l
liftL7 :: forall l.
LaTeXC l =>
(LaTeX
 -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX)
-> l -> l -> l -> l -> l -> l -> l -> l
liftL7 LaTeX
-> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f l
x1 l
x2 l
x3 l
x4 l
x5 l
x6 l
x7 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4,LaTeX
x5,LaTeX
x6,LaTeX
x7] -> LaTeX
-> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4 LaTeX
x5 LaTeX
x6 LaTeX
x7) [l
x1,l
x2,l
x3,l
x4,l
x5,l
x6,l
x7]

-- | Variant of 'liftL' with an eight arguments function.
liftL8 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l -> l
liftL8 :: forall l.
LaTeXC l =>
(LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX)
-> l -> l -> l -> l -> l -> l -> l -> l -> l
liftL8 LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
f l
x1 l
x2 l
x3 l
x4 l
x5 l
x6 l
x7 l
x8 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4,LaTeX
x5,LaTeX
x6,LaTeX
x7,LaTeX
x8] -> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4 LaTeX
x5 LaTeX
x6 LaTeX
x7 LaTeX
x8) [l
x1,l
x2,l
x3,l
x4,l
x5,l
x6,l
x7,l
x8]

-- | Variant of 'liftL' with a nine arguments function.
liftL9 :: LaTeXC l => (LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX -> LaTeX) -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
liftL9 :: forall l.
LaTeXC l =>
(LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX
 -> LaTeX)
-> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
liftL9 LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
f l
x1 l
x2 l
x3 l
x4 l
x5 l
x6 l
x7 l
x8 l
x9 = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\[LaTeX
x1,LaTeX
x2,LaTeX
x3,LaTeX
x4,LaTeX
x5,LaTeX
x6,LaTeX
x7,LaTeX
x8,LaTeX
x9] -> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
-> LaTeX
f LaTeX
x1 LaTeX
x2 LaTeX
x3 LaTeX
x4 LaTeX
x5 LaTeX
x6 LaTeX
x7 LaTeX
x8 LaTeX
x9) [l
x1,l
x2,l
x3,l
x4,l
x5,l
x6,l
x7,l
x8,l
x9]


-- | Map the given functor of LaTeX values to fixed TeX arguments.
fixArgs :: Functor f => f LaTeX -> f TeXArg
fixArgs :: forall (f :: * -> *). Functor f => f LaTeX -> f TeXArg
fixArgs = forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap LaTeX -> TeXArg
FixArg

-- | Map the first 'n' elements as optional arguments, and the remaining ones as
-- fixed arguments. Most LaTeX commands are structured with first a sequence of
-- optional arguments, followed by a sequence of fixed arguments.
optFixArgs :: Int -> [LaTeX] -> [TeXArg]
optFixArgs :: Int -> [LaTeX] -> [TeXArg]
optFixArgs Int
_ [] = []
optFixArgs Int
k xa :: [LaTeX]
xa@(LaTeX
x:[LaTeX]
xs) | Int
k forall a. Ord a => a -> a -> Bool
<= Int
0 = forall a b. (a -> b) -> [a] -> [b]
map LaTeX -> TeXArg
FixArg [LaTeX]
xa
                       | Bool
otherwise = LaTeX -> TeXArg
OptArg LaTeX
x forall a. a -> [a] -> [a]
: Int -> [LaTeX] -> [TeXArg]
optFixArgs (Int
kforall a. Num a => a -> a -> a
-Int
1) [LaTeX]
xs

-- | Call a LaTeX command where all the arguments in the list are fixed
-- arguments.
fixComm :: LaTeXC l => String -> [l] -> l
fixComm :: forall l. LaTeXC l => String -> [l] -> l
fixComm String
str = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (String -> [TeXArg] -> LaTeX
TeXComm String
str forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall (f :: * -> *). Functor f => f LaTeX -> f TeXArg
fixArgs)

-- | Call a LaTeX command with the first 'n' arguments as optional ones,
-- followed by fixed arguments. Most LaTeX commands are structured with first a
-- sequence of optional arguments, followed by a sequence of fixed arguments.
optFixComm :: LaTeXC l => String -> Int -> [l] -> l
optFixComm :: forall l. LaTeXC l => String -> Int -> [l] -> l
optFixComm String
str Int
k = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (String -> [TeXArg] -> LaTeX
TeXComm String
str forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> [LaTeX] -> [TeXArg]
optFixArgs Int
k)

-- | Create a LaTeX environment where all the arguments in the list are fixed
--   arguments.
fixEnv :: LaTeXC l => String -> [l] -> l -> l
fixEnv :: forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l]
args l
inner = forall l. LaTeXC l => ([LaTeX] -> LaTeX) -> [l] -> l
liftListL (\(LaTeX
inn:[LaTeX]
as) -> String -> [TeXArg] -> LaTeX -> LaTeX
TeXEnv String
str (forall (f :: * -> *). Functor f => f LaTeX -> f TeXArg
fixArgs [LaTeX]
as) LaTeX
inn) (l
innerforall a. a -> [a] -> [a]
:[l]
args)

-- | A simple (without arguments) and handy command generator
--   using the name of the command.
--
-- > comm0 str = fromLaTeX $ TeXComm str []
--
comm0 :: LaTeXC l => String -> l
comm0 :: forall l. LaTeXC l => String -> l
comm0 String
str = forall l. LaTeXC l => LaTeX -> l
fromLaTeX forall a b. (a -> b) -> a -> b
$ String -> [TeXArg] -> LaTeX
TeXComm String
str []

-- | 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]
--
comm1 :: LaTeXC l => String -> l -> l
comm1 :: forall l. LaTeXC l => String -> l -> l
comm1 String
str l
l1 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1]

-- | 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]
--
comm2 :: LaTeXC l => String -> l -> l -> l
comm2 :: forall l. LaTeXC l => String -> l -> l -> l
comm2 String
str l
l1 l
l2 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2]

-- | A three parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm3 str = liftL3 $ \l1 l2 l3 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3]
--
comm3 :: LaTeXC l => String -> l -> l -> l -> l
comm3 :: forall l. LaTeXC l => String -> l -> l -> l -> l
comm3 String
str l
l1 l
l2 l
l3 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3]

-- | A four parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm4 str = liftL4 $ \l1 l2 l3 l4 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4]
--
comm4 :: LaTeXC l => String -> l -> l -> l -> l -> l
comm4 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l
comm4 String
str l
l1 l
l2 l
l3 l
l4 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4]

-- | A five parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm5 str = liftL5 $ \l1 l2 l3 l4 l5 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5]
--
comm5 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l
comm5 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l -> l
comm5 String
str l
l1 l
l2 l
l3 l
l4 l
l5 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4, l
l5]

-- | A six parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm6 str = liftL6 $ \l1 l2 l3 l4 l5 l6 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6]
--
comm6 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l
comm6 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l
comm6 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6]

-- | A seven parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm7 str = liftL7 $ \l1 l2 l3 l4 l5 l6 l7 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7]
--
comm7 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l
comm7 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l
comm7 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7]

-- | An eight parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm8 str = liftL8 $ \l1 l2 l3 l4 l5 l6 l7 l8 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7, FixArgs l8]
--
comm8 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l
comm8 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l -> l
comm8 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 l
l8 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7, l
l8]

-- | A nine parameter command generator using the name of the command.
--   The parameters will be rendered as fixed arguments.
--
-- > comm9 str = liftL9 $ \l1 l2 l3 l4 l5 l6 l7 l8 l9 -> TeXComm str [FixArg l1, FixArg l2, FixArg l3, FixArg l4, FixArg l5, FixArg l6, FixArg l7, FixArgs l8, l9]
--
comm9 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
comm9 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
comm9 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 l
l8 l
l9 = forall l. LaTeXC l => String -> [l] -> l
fixComm String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7, l
l8, l
l9]


-- | Like 'comm0' but using 'TeXCommS', i.e. no \"{}\" will be inserted to protect
-- the command's end.
--
-- > commS = fromLaTeX . TeXCommS
--
commS :: LaTeXC l => String -> l
commS :: forall l. LaTeXC l => String -> l
commS = forall l. LaTeXC l => LaTeX -> l
fromLaTeX forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> LaTeX
TeXCommS

-- | Define an environment, without any parameters that are passed to the
--   environment.
env0 :: LaTeXC l => String -> l -> l
env0 :: forall l. LaTeXC l => String -> l -> l
env0 String
str = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str []

-- | Define an environment, with one fixed parameter that is passed to the
--   environment.
env1 :: LaTeXC l => String -> l -> l -> l
env1 :: forall l. LaTeXC l => String -> l -> l -> l
env1 String
str l
l1 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1]

-- | Define an environment, with two fixed parameters that is passed to the
--   environment.
env2 :: LaTeXC l => String -> l -> l -> l -> l
env2 :: forall l. LaTeXC l => String -> l -> l -> l -> l
env2 String
str l
l1 l
l2 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2]

-- | Define an environment, with three fixed parameters that is passed to the
--   environment.
env3 :: LaTeXC l => String -> l -> l -> l -> l -> l
env3 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l
env3 String
str l
l1 l
l2 l
l3 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3]

-- | Define an environment, with four fixed parameters that is passed to the
--   environment.
env4 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l
env4 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l -> l
env4 String
str l
l1 l
l2 l
l3 l
l4 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4]

-- | Define an environment, with five fixed parameters that is passed to the
--   environment.
env5 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l
env5 :: forall l. LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l
env5 String
str l
l1 l
l2 l
l3 l
l4 l
l5 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4, l
l5]

-- | Define an environment, with six fixed parameters that is passed to the
--   environment.
env6 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l
env6 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l
env6 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6]

-- | Define an environment, with seven fixed parameters that is passed to the
--   environment.
env7 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l
env7 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l -> l
env7 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7]

-- | Define an environment, with eight fixed parameters that is passed to the
--   environment.
env8 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
env8 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
env8 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 l
l8 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7, l
l8]

-- | Define an environment, with nine fixed parameters that is passed to the
--   environment.
env9 :: LaTeXC l => String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
env9 :: forall l.
LaTeXC l =>
String -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l -> l
env9 String
str l
l1 l
l2 l
l3 l
l4 l
l5 l
l6 l
l7 l
l8 l
l9 = forall l. LaTeXC l => String -> [l] -> l -> l
fixEnv String
str [l
l1, l
l2, l
l3, l
l4, l
l5, l
l6, l
l7, l
l8, l
l9]

-- | A lifted version of the 'TeXBraces' constructor.
--
-- > braces = liftL TeXBraces
--
braces :: LaTeXC l => l -> l
braces :: forall l. LaTeXC l => l -> l
braces = forall l. LaTeXC l => (LaTeX -> LaTeX) -> l -> l
liftL LaTeX -> LaTeX
TeXBraces

squareBraces :: LaTeXC l => l -> l
squareBraces :: forall l. LaTeXC l => l -> l
squareBraces = forall l. LaTeXC l => (LaTeX -> LaTeX) -> l -> l
liftL forall a b. (a -> b) -> a -> b
$ \LaTeX
l -> Text -> LaTeX
TeXRaw Text
"[" forall a. Semigroup a => a -> a -> a
<> LaTeX
l forall a. Semigroup a => a -> a -> a
<> Text -> LaTeX
TeXRaw Text
"]" 

-- | Insert a raw piece of 'Text'.
-- This functions doesn't escape @LaTeX@ reserved characters,
-- it insert the text just as it is received.
--
-- /Warning:/ This function is /unsafe/, in the sense that it does
-- not check that the input text is a valid LaTeX /block/.
-- Make sure any braces, commands or environments are properly closed.
raw :: LaTeXC l => Text -> l
raw :: forall l. LaTeXC l => Text -> l
raw = forall l. LaTeXC l => LaTeX -> l
fromLaTeX forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> LaTeX
TeXRaw