packages feed

lhs2tex (empty) → 1.12

raw patch · 167 files changed

+17691/−0 lines, 167 filesdep +basedep +regex-compatbuild-type:Customsetup-changedbinary-added

Dependencies added: base, regex-compat

Files

+ AUTHORS view
@@ -0,0 +1,5 @@+Ralf Hinze (original version)+Andres Loeh (poly mode, maintainer)+Stefan Wehr (adjust patch)+Brian Smith (Cabal/Windows patch)+
+ Auxiliaries.lhs view
@@ -0,0 +1,156 @@+%-------------------------------=  --------------------------------------------+\subsection{Auxiliaries}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Auxiliaries            (  module Auxiliaries  )+> where+>+> import Data.Char              (  isSpace  )+> import Control.Monad          (  MonadPlus(..)  )++%endif++> infixr 9 {-"\;"-} .>  -- same fixity as `|.|'+> infixr 5 {-"\;"-} <|  -- same fixity as `|:|'+> infixr 0 {-"\;"-} @@, @>++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Operations on chars}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> unNL                          :: Char -> Char+> unNL '\n'                     =  ' '+> unNL c                        =  c++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Operations on lists}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> rtake                         :: Int -> [a] -> [a]+> rtake n                       =  reverse . take n . reverse++> inverse                       :: [(a, b)] -> [(b, a)]+> inverse bs                    =  [ (b, a) | (a, b) <- bs ]++> merge                         :: (Ord a) => [a] -> [a] -> [a]+> merge [] bs                   =  bs+> merge as@(a : _) []           =  as+> merge as@(a : as')  bs@(b : bs')+>     | a <= b                  =  a : merge as' bs+>     | otherwise               =  b : merge as  bs'++%{+%format (sub (a) (b)) = "{" a "}_{" b "}"+The call |breakAfter p [sub a 1,..,sub a n]| yields |([sub a 1,..,sub a+i], [sub a (i+1),..,sub a n])| such that |p (sub a i) = True| and |p+(sub a j) = False| for |j < i|.+%}++> breakAfter                    :: (a -> Bool) -> [a] -> ([a], [a])+> breakAfter p []               =  ([], [])+> breakAfter p (a : as)+>     | p a                     =  ([a], as)+>     | otherwise               =  a <| breakAfter p as++> breaks                        :: ([a] -> Bool) -> [a] -> ([a], [a])+> breaks p []                   =  ([], [])+> breaks p as@(a : as')+>     | p as                    =  ([], as)+>     | otherwise               =  a <| breaks p as'++> isPrefix                      :: (Eq a) => [a] -> [a] -> Bool+> p `isPrefix` as               =  p == take (length p) as+ +> withoutSpaces                 :: String -> String+> withoutSpaces s               =  filter (not . isSpace) s++> intersperse                   :: a -> [a] -> [a]+> intersperse s []              =  []+> intersperse s (a : as)        =  a : intersperse1 as+>   where intersperse1 []       =  []+>         intersperse1 (a : as) =  s : a : intersperse1 as++> group                         :: Int -> [a] -> [[a]]+> group n                       =  repSplit (repeat n) .> takeWhile (not . null)++> repSplit                      :: [Int] -> [a] -> [[a]]+> repSplit [] xs                =  []+> repSplit (n : ns) xs          =  ys : repSplit ns zs+>   where (ys, zs)              =  splitAt n xs++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Monad utilities}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> lift                          :: (Monad m) => (a -> b) -> (a -> m b)+> lift f a                      =  return (f a)++Kleisli and reverse Kleisli composition.++> (@@)                          :: (Monad m) => (a -> m b) -> (c -> m a) -> c -> m b+> f @@ g                        =  \a -> g a >>= f+>+> (@>)                          :: (Monad m) => (a -> m b) -> (b -> m c) -> a -> m c+> f @> g                        =  \a -> f a >>= g+>+> (***)                         :: Monad m => (a -> m a') -> (b -> m b') -> (a, b) -> m (a', b')+> m *** n                       =  \(a, b) -> do { a' <- m a; b' <- n b; return (a', b') }++> many                          :: (MonadPlus m) => m a -> m [a]+> many m                        =  do { a <- m; as <- many m; return (a : as) }+>                                  `mplus` return []+>+> optional                      :: (MonadPlus m) => m a -> m (Maybe a)+> optional m                    =  do { a <- m; return (Just a) }+>                                  `mplus` return Nothing+++|Either| as an exception monad.++> instance Functor (Either a) where+>     fmap f (Left  a)          =  Left  a+>     fmap f (Right b)          =  Right (f b)+>+> instance Monad (Either a) where+>     Left  a >>= k             =  Left a+>     Right b >>= k             =  k b+>     return                    =  Right+>+> fromRight                     :: Either a b -> b+> fromRight (Left _)            =  error "fromRight"+> fromRight (Right b)           =  b++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Miscellaneous}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Some useful type abbreviations.++> type LineNo                   =  Int+> type Message                  =  String+> type Exc                      =  (Message, String)++Reverse Composition.++> (.>)                          :: (a -> b) -> (b -> c) -> a -> c+> f .> g                        =  \a -> g (f a)+>+> (<|)                          :: a -> ([a], b) -> ([a], b)+> a <| (as, b)                  =  (a : as, b)+>+> impossible                    :: String -> a+> impossible name               =  error ("The `impossible' happened in \""+>                                         ++ name ++ "\"")++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Obsolete code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> command                       :: String -> String -> String+> command name arg              =  "\\" ++ name ++ "{" ++ arg ++ "}"+>+> environment                   :: String -> String -> String+> environment name m            =  "\\begin{" ++ name ++ "}" ++ m+>                               ++ "\\end{" ++ name ++ "}"
+ Directives.lhs view
@@ -0,0 +1,243 @@+%-------------------------------=  --------------------------------------------+\subsection{Directives}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Directives             (  Formats, parseFormat, Equation, Substs, Subst, parseSubst, Toggles, eval, define, value, nrargs  )+> where+>+> import Data.Char              (  isSpace, isAlpha, isDigit  )+> import Control.Monad+> import Parser+> import TeXCommands+> import TeXParser+> import HsLexer+> import FiniteMap              (  FiniteMap  )+> import qualified FiniteMap as FM+> import FiniteMap ( (!) )+> import Auxiliaries+> import Document+> import Value++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{@%format@ directives}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> type Formats                  =  FiniteMap Char Equation+> type Equation                 =  (Bool, [Bool], [String], [Token])++ks, 20.07.03: The |Equation| type contains the following information:+does the definition have surrounding parentheses, do the arguments+have surrounding parentheses, what are the names of the arguments,+and the tokens to replace the macro with.++ks, 06.09.03: Adding the |nrargs| function that yields the number of+arguments a formatting directive expects.++> nrargs                        :: Equation -> Int+> nrargs (_,_,args,_)           =  length args++\NB Die Substution wird nicht als Funktion |[[Token]] -> [Token]|+repr"asentiert, da math |Pos Token| verlangt.++>+> parseFormat                   :: String -> Either Exc (String, Equation)+> parseFormat s                 =  parse equation (convert s)++Format directives. \NB @%format ( = "(\;"@ is legal.++> equation                      :: Parser Token (String, Equation)+> equation                      =  do (opt, (f, opts, args)) <- optParen lhs+>                                     _ <- varsym "="+>                                     r <- many item+>                                     return (f, (opt, opts, args, r))+>                               `mplus` do f <- item+>                                          _ <- varsym "="+>                                          r <- many item+>                                          return (string f, (False, [], [], r))+>                               `mplus` do f <- satisfy isVarid `mplus` satisfy isConid+>                                          return (string f, (False, [], [], tex f))++\Todo{@%format `div1`@ funktioniert nicht.}++>     where+>     tex (Varid s)             =  subscript Varid s+>     tex (Conid s)             =  subscript Conid s+>     tex (Qual [] s)           =  tex s+>     tex (Qual (m:ms) s)       =  Conid m : tex (Qual ms s)+>      -- ks, 03.09.2003: was "tex (Qual m s) = Conid m : tex s"; +>      -- seems strange though ...+>     subscript f s  +>       | null t && not (null w) && (null v || head w == '_')+>                               =  underscore f s+>       | otherwise             =  [f (reverse w)+>                                  , TeX (Text ((if   not (null v)+>                                                then "_{" ++ reverse v ++ "}" +>                                                else ""+>                                               ) ++ reverse t))+>                                  ]+>         where s'              =  reverse s+>               (t, u)          =  span (== '\'') s'+>               (v, w)          =  span isDigit u++ks, 02.02.2004: I have added implicit formatting via |underscore|.+The above condition should guarantee that it is (almost) only used in +cases where previously implicit formatting did not do anything useful.+The function |underscore| typesets an identifier such as+|a_b_c| as $a_{b_{c}}$. TODO: Instead of hard-coded subscripting a+substitution directive should be invoked here.++>     underscore f s+>                               =  [f t]+>                                  ++ if null u then []+>                                               else [TeX (Text ("_{"))]+>                                                    +++>                                                    proc_u+>                                                    +++>                                                    [TeX (Text ("}"))]+>         where (t, u)          =  break (== '_') s+>               tok_u           =  tokenize (tail u)+>               proc_u          =  case tok_u of+>                                    Left  _ -> [f (tail u)] -- should not happen+>                                    Right t -> t++> lhs                           :: Parser Token (String, [Bool], [String])+> lhs                           =  do f <- varid `mplus` conid+>                                     as <- many (optParen varid)+>                                     let (opts, args) = unzip as+>                                     return (f, opts, args)++> optParen                      :: Parser Token a -> Parser Token (Bool, a)+> optParen p                    =  do _ <- open'; a <- p; _ <- close'; return (True, a)+>                               `mplus` do a <- p ; return (False, a)+>+> item                          =  satisfy (\_ -> True)++> convert []                    =  []+> convert ('"' : '"' : s)       =  '"' : convert s+> convert ('"' : s)             =  '{' : '-' : '"' : convert' s+> convert (c : s)               =  c : convert s+>+> convert' []                   =  []+> convert' ('"' : '"' : s)      =  '"' : convert' s+> convert' ('"' : s)            =  '"' : '-' : '}' : convert s+> convert' (c : s)              =  c : convert' s++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{@%subst@ directives}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> type Substs                   =  FiniteMap Char Subst+> type Subst                    =  [Doc] -> Doc++> parseSubst                    :: String -> Either Exc (String, Subst)+> parseSubst s                  =  parse substitution (convert s)+>+> substitution                  =  do s <- varid+>                                     args <- many varid+>                                     _ <- varsym "="+>                                     rhs <- many (satisfy isVarid `mplus` satisfy isTeX)+>                                     return (s, subst args rhs)+>   where+>   subst args rhs ds           =  catenate (map sub rhs)+>       where sub (TeX d)       =  d+>             sub (Varid x)     =  FM.fromList (zip args ds) ! x++\Todo{unbound variables behandeln.}++> varid                         =  do x <- satisfy isVarid; return (string x)+> conid                         =  do x <- satisfy isConid; return (string x)+> varsym s                      =  satisfy (== (Varsym s))+>+> isTeX (TeX _)                 =  True+> isTeX _                       =  False++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Conditional directives}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> type Toggles                  =  FiniteMap Char Value++Auswertung Boole'scher Ausdr"ucke.++> eval                          :: Toggles -> String -> Either Exc Value+> eval togs                     =  parse (expression togs)+>+> expression                    :: Toggles -> Parser Token Value+> expression togs               =  expr+>   where+>   expr                        =  do e1 <- appl+>                                     e2 <- optional (do op <- varsym'; e <- expr; return (op, e))+>                                     return (maybe e1 (\(op, e2) -> sys2 op e1 e2) e2)+>   appl                        =  do f <- optional not'+>                                     e <- atom+>                                     return (maybe e (\_ -> onBool1 not e) f)+>   atom                        =  do Varid x <- satisfy isVarid; return (value togs x)+>                               `mplus` do _ <- true'; return (Bool True)+>                               `mplus` do _ <- false'; return (Bool False)+>                               `mplus` do s <- satisfy isString; return (Str (read (string s)))+>                               `mplus` do s <- satisfy isNumeral; return (Int (read (string s)))+>                               `mplus` do _ <- open'; e <- expr; _ <- close'; return e+>+> sys2 "&&"                     =  onBool2 (&&)+> sys2 "||"                     =  onBool2 (||)+> sys2 "=="                     =  onMatching (==) (==) (==)+> sys2 "/="                     =  onMatching (/=) (/=) (/=)+> sys2 "<"                      =  onMatching (<) (<) (<)+> sys2 "<="                     =  onMatching (<=) (<=) (<=)+> sys2 ">="                     =  onMatching (>=) (>=) (>=)+> sys2 ">"                      =  onMatching (>) (>) (>)+> sys2 "++"                     =  onStr2 (++)+> sys2 "+"                      =  onInt2 (+)+> sys2 "-"                      =  onInt2 (-)+> sys2 "*"                      =  onInt2 (*)+> sys2 "/"                      =  onInt2 (div)+> sys2 _                        =  \_ _ -> Undef++Definierende Gleichungen.++> define                        :: Toggles -> String -> Either Exc (String, Value)+> define togs                   =  parse (definition togs)+>+> definition                    :: Toggles -> Parser Token (String, Value)+> definition togs               =  do Varid x <- satisfy isVarid+>                                     _ <- equal'+>                                     b <- expression togs+>                                     return (x, b)++Primitive Parser.++> equal', not',  true', false', open', close'+>                               :: Parser Token Token+> equal'                        =  satisfy (== (Varsym "="))+> not'                          =  satisfy (== (Varid "not"))+> true'                         =  satisfy (== (Conid "True"))+> false'                        =  satisfy (== (Conid "False"))+> open'                         =  satisfy (== (Special '('))+> close'                        =  satisfy (== (Special ')'))++> varsym'                       =  do x <- satisfy isVarsym; return (string x)+> isVarsym (Varsym _)           =  True+> isVarsym _                    =  False+> isString (String _)           =  True+> isString _                    =  False+> isNumeral (Numeral _)         =  True+> isNumeral _                   =  False++Hilfsfunktionen.++> parse                         :: Parser Token a -> [Char] -> Either Exc a+> parse p str                   =  do ts <- tokenize str+>                                     let ts' = filter (\t -> catCode t /= White || isTeX t) ts+>                                     maybe (Left msg) Right (run p ts')+>     where msg                 =  ("syntax error in directive", str)++Hack: |isTeX t| f"ur |parseSubst|.++> value                         :: Toggles -> String -> Value+> value togs x                  =  case FM.lookup x togs of+>     Nothing                   -> Undef+>     Just b                    -> b
+ Document.lhs view
@@ -0,0 +1,74 @@+%-------------------------------=  --------------------------------------------+\subsection{Document type}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Document ( module Document )+> where++%endif++> infixr 5 {-"\enskip"-} <>  -- same fixity as `|++|'++The pretty printer generate documents of type |Doc|.++> data Doc                      =  Empty+>                               |  Text String+>                               |  Doc :^: Doc+>                               |  Embedded String+>                               |  Sub String [Doc]+>                                  deriving (Eq, Show)++|Embedded| is used for embedded pseudo \TeX\ text (eg in comments);+|Sub s ds| is used for replacements (eg |Sub "inline" [..]|).++> (<>)                          :: Doc -> Doc -> Doc+> Empty <> d                    =  d+> d <> Empty                    =  d+> d1 <> d2                      =  d1 :^: d2+>+> catenate                      :: [Doc] -> Doc+> catenate                      =  foldr (<>) Empty++Substitution strings.++> sub'thin                      =  Sub "thinspace" []+> sub'space                     =  Sub "space" []+> sub'nl                        =  Sub "newline" []+> sub'verbnl                    =  Sub "verbnl" []+> sub'blankline                 =  Sub "blankline" []+> sub'dummy                     =  Sub "dummy" []+>+> sub'spaces a                  =  Sub "spaces" [a]+> sub'special a                 =  Sub "special" [a]+> sub'verb a                    =  Sub "verb" [a]+> sub'verbatim a                =  Sub "verbatim" [a]+> sub'inline a                  =  Sub "inline" [a]+> sub'code a                    =  Sub "code" [a]+> sub'conid a                   =  Sub "conid" [a]+> sub'varid a                   =  Sub "varid" [a]+> sub'consym a                  =  Sub "consym" [a]+> sub'varsym a                  =  Sub "varsym" [a]+> sub'numeral a                 =  Sub "numeral" [a]+> sub'char a                    =  Sub "char" [a]+> sub'string a                  =  Sub "string" [a]+> sub'comment a                 =  Sub "comment" [a]+> sub'nested a                  =  Sub "nested" [a]+> sub'pragma a                  =  Sub "pragma" [a]+> sub'keyword a                 =  Sub "keyword" [a]+> sub'column1 a                 =  Sub "column1" [a]+> sub'hskip a                   =  Sub "hskip" [a]+> sub'phantom a                 =  Sub "phantom" [a]+>+> sub'column3 a1 a2 a3          =  Sub "column3" [a1, a2, a3]++Additional substitutions for the new @poly@ formatter.+Added by ks, 14.05.2003.++> sub'fromto b e a              =  Sub "fromto" [Text b,Text e,a]+> sub'column n a                =  Sub "column" [Text n,a]+> sub'centered                  =  Sub "centered" []+> sub'left                      =  Sub "left" []+> sub'dummycol                  =  Sub "dummycol" []+> sub'indent n                  =  Sub "indent" [n]
+ Examples/Calc.lhs view
@@ -0,0 +1,33 @@+\documentclass{article}++%include polycode.fmt++% preparation, can go into preamble+\newcommand\calculationcomments{%+  \def\commentbegin{\{ }%+  \def\commentend{\}}}%++%space adjustment, can also be defined globally:+%format ^^^ = "\quad "++\begin{document}++%concrete calculation example:+\begingroup% keep comment change local to group+\calculationcomments+\begin{spec}+   2 * (sum (Succ n'))+=  ^^^  {- definition of sum -}+   2 * ((Succ n') + (sum n'))+=       {- distributivity -}+   2 * (Succ n') + 2 * (sum n')+=       {- IH -}+   2 * (Succ n') + n * (Succ n')+=       {- distributivity -}+   (2 + n) * (Succ n')+=       {- commutativity, definition of + -}+   (Succ n') * (Succ (Succ n'))+\end{spec}+\endgroup++\end{document}
+ Examples/CalcExample.lhs view
@@ -0,0 +1,40 @@+\documentclass{article}++%include lhs2TeX.fmt+%include lhs2TeX.sty+%include polycode.fmt++\newenvironment{calculation}{%+  \renewcommand\commentbegin{\qquad\{\ }%+  \renewcommand\commentend{\}}%+  \setlength{\blanklineskip}{1ex}%+  \renewcommand\hsindent[1]{\qquad}}{}+  +\begin{document}+\begin{calculation}+\begin{spec}+    map (+1) [1,2,3]++==    {- desugaring of |(:)| -}++    map (+1) (1 : [2,3])++==    {- definition of |map| -}++    (+1) 1  :  map (+1) [2,3]++==    {- performing the addition on the head -}++    2       :  map (+1) [2,3]++==    {- recursive application of |map| -}++    2       :  [3,4]++==    {- list syntactic sugar -}++    [2,3,4]+\end{spec}+\end{calculation}++\end{document}
+ Examples/FormatAlign.lhs view
@@ -0,0 +1,35 @@+\documentclass{article}++%include lhs2TeX.fmt+%include lhs2TeX.sty+%include spacing.fmt++\begin{document}++It is irrelevant how typ is formatted, but it must be a parametrized+format for the bug to be triggered.++%format typ(a) = a++This is a @lhs2TeX@ bug. The double colons are not aligned, although+they should be.++\begin{code}+map    ^^  typ( a1 :: *, a2 :: * )                             ::  (map ^^ typ(a1,a2)) => a1 -> a2+zipWith^^  typ( a1 :: *, a2 :: *, a3 :: * )                    ::  (zipWith ^^ typ(a1,a2,a3)) => a1 -> a2 -> a3 +collect^^  typ( a :: * | b :: * )                              ::  (collect ^^ typ(a | b)) => a -> [c]+equal  ^^  typ( a :: * )                                       ::  (  enum ^^ typ(a), equal ^^ typ(a)) +                                                                          => a -> a -> Bool ^^.+\end{code}++This is a workaround:++\begin{code}+map    ^^  typ( a1 :: *, a2 :: * )              ^              ::  (map ^^ typ(a1,a2)) => a1 -> a2+zipWith^^  typ( a1 :: *, a2 :: *, a3 :: * )     ^              ::  (zipWith ^^ typ(a1,a2,a3)) => a1 -> a2 -> a3 +collect^^  typ( a :: * | b :: * )               ^              ::  (collect ^^ typ(a | b)) => a -> [c]+equal  ^^  typ( a :: * )                        ^              ::  (  enum ^^ typ(a), equal ^^ typ(a)) +                                                                          => a -> a -> Bool ^^.+\end{code}++\end{document}
+ Examples/HelloWorld.lhs view
@@ -0,0 +1,10 @@+\documentclass{article}+%include polycode.fmt+\begin{document}+This is the famous ``Hello world'' example,+written in Haskell:+\begin{code}+main  ::  IO ()+main  =   putStrLn "Hello, world!"+\end{code}+\end{document}
+ Examples/MaxSegment.lhs view
@@ -0,0 +1,79 @@+% lhs2TeX -verb MaxSegment.lhs > MaxSegment.tex+% lhs2TeX -math -align 33 MaxSegment.lhs > MaxSegment.tex++\documentclass{article}+\usepackage[german]{babel}++%-------------------------------=  --------------------------------------------++%include ../lhs2TeX.sty+%include ../lhs2TeX.fmt++%-------------------------------=  --------------------------------------------++%if style == math+%format alpha			=  "\alpha "+%format a1+%format an 	   		= a "_n"+%elif style == verb+%format a1       		= "a$_1$"+%format an       		= "a$_n$"+%endif++\begin{document}++So ist |\x -> x + 1| die Nachfolgerfunktion.++Diese Aufgabe ist dem Artikel `Proofs as Programs' von Bates und+Constable entnommen.  Gegeben ist eine Folge von ganzen Zahlen |[a1,+..., an]|. Finde die zusammenh"angende Teilfolge, deren Summe maximal+ist unter allen zusammenh"angenden Teilfolgen. F"ur die Folge++> seg				:: [Integer]+> seg				=  [-3, 2, -5, 3, -1, 2]++ist die Teilfolge |[3, -1, 2]| mit der Summe |4| maximal.+	Die Funktion |segments x| berechnet  alle zusammenh"angenden+Segmente der Liste |x|.++> type Segment alpha		=  [alpha]++> segments			:: [a] -> [Segment a]+> segments x			=  s ++ t+>     where (s, t)		=  segments' x++Ist das Ergebnis der Hilfsfunktion |segments x| das Tupel |(s, t)|, so+enth"alt |s| alle echten Pr"afixe von |x| und |t| alle "ubrigen+Segmente von |x|.++> segments'			:: [a] -> ([Segment a], [Segment a])+> segments' []			=  ([], [])+> segments' (a : x)		=  ([a] : [ a : y | y <- s ], s ++ t)+>     where (s, t)		=  segments' x++Die Funktion |maxSegment x| berechnet auf effiziente Weise die L"osung+f"ur das oben genannte Problem, d.h. sie realisiert die folgende+Spezifikation.++< maxSegment			:: (Num a, Ord a) => [a] -> a+< maxSegment x			=  maximum [ sum s | s <- segments x ]++Die Vorgehensweise entspricht im wesentlichen dem oben geschilderten+Verfahren. Beachte, da"s |maxSegment []| undefiniert ist.++> maxSegment			:: (Num a, Ord a) => [a] -> a+> maxSegment x			=  snd (maxSegment' x)+>+> maxSegment'			:: (Num a, Ord a) => [a] -> (a, a)+> maxSegment' [a]		=  (a, a)+> maxSegment' (a : x)		=  (n, m `max` n)+>     where (l, m)		=  maxSegment' x+>           n			=  a `max` (a + l)++Zur "Ubung: erweitere |maxSegment|, so da"s nicht nur die Summe,+sondern zus"atzlich, das dazugeh"orige Segment zur"uckgegeben wird.++< min a b | a <= b	       	=  a		-- vordefiniert+<         | otherwise		=  b++\end{document}
+ Examples/NewCode.lhs view
@@ -0,0 +1,18 @@+%include lhs2TeX.fmt+This is to demonstrate the new code mode.+We can use formatting instructions in code mode, too,+for instance to support template Haskell:++%format splice(a) = "$(" a ")"+%format out = "putStrL"+%format hello = "'dHello'd"+%format flip(a)(b) = b ^^ a+%format ^^ = " "++\begin{code}+-- one line comment+{- nested comment -}+{-# pragma #-}+main = flip(hello)(out)+\end{code}+
+ Examples/Sort.lhs view
@@ -0,0 +1,73 @@+%if False++This is an example file that demonstrates the use of lhs2TeX.+Compile it with++lhs2TeX --math Sort.lhs > Sort.tex++and then run it through LaTeX.++The "if False" in the first line is an lhs2TeX directive. All+directives start with a % character. You can use the "if" directive to+conditionally include or exclude certain parts of your document. An+"if False" statement can be used to start a comment that will not+appear in the TeX output.++To make this a valid TeX document, we will start with a \documentclass+command, after closing this comment block by means of an "endif"+directive.++%endif++\documentclass{article}++%if False+We will now include the two files that are required for+using lhs2TeX, using the "include" directive.+To activate alignment of the code blocks, we set the+alignment column to 33, using the "align" directive.+%endif++%include lhs2TeX.fmt+%include lhs2TeX.sty+%align 33++%if False++Another use for conditionals is to exclude parts of the code+that are needed to make the module correct Haskell, but should+not appear in the typeset version. We place the Haskell module+header here.++> module Sort where++Now we start the TeX document with \begin{document}+and then include the module body that will be typeset:++%endif++\begin{document}++> quickSort                     :: (Ord a) => [a] -> [a]+> quickSort []                  =  []+> quickSort (a : as)            =  quickSort [ b | b <- as, b <= a ]+>                               ++ a : quickSort [ b | b <- as, b > a ]+>+> mergeSort                     :: (Ord a) => [a] -> [a]+> mergeSort []                  =  []+> mergeSort [a]                 =  [a]+> mergeSort as                  =  merge (mergeSort bs) (mergeSort cs)+>     where (bs, cs)            =  splitAt (length as `div` 2) as++The worst case execution time of |mergeSort| is $\Theta(n\log n)$.+NB. |splitAt| is given by++< splitAt                       :: Int -> [a] -> ([a], [a])+< splitAt k as                  =  (take k as, drop k as) {-"\enskip."-}++%if False+Finally, we have to end the LaTeX document and are done.+%endif++\end{document}+
+ Examples/TestPoly.lhs view
@@ -0,0 +1,21 @@+\documentclass{beamer}++%include lhs2TeX.fmt+\setlength{\parskip}{5pt}++\begin{document}++\section{Normal}++\frame{%+foo foo foo++> x :: Int++\onslide<2->%++> x :: Char++bar bar bar}++\end{document}
+ Examples/Unlit.lhs view
@@ -0,0 +1,128 @@+% lhs2TeX -math -align 33 Unlit.lhs > Unlit.tex++\documentclass{article}+\usepackage[german]{babel}++%-------------------------------=  --------------------------------------------++%include ../lhs2TeX.sty+%include ../lhs2TeX.fmt++%-------------------------------=  --------------------------------------------++\begin{document}++%-------------------------------=  --------------------------------------------+\section{\texttt{unlit}}+%-------------------------------=  --------------------------------------------++Literate-Skripte, die Bird-Tracks verwenden, in Skripte "uberf"uhren,+die die Pseudo-\TeX-Kommandos \verb|\begin{code}|, \verb|\end{code}|+verwenden. Das Programm realisiert einen einfachen UNIX-Filter.++Synopsis:+%+\begin{verbatim}+unlit+unlit <file>+\end{verbatim}++%-------------------------------=  --------------------------------------------++%if code || showModuleHeader++> module Main			(  main  )+> where+>+> import Char			(  isSpace  )+> import System			(  getArgs  )+> import Auxiliaries		(  (.>)  )++%endif++> data Class			=  Program LineNo Line+>				|  Spec    LineNo Line+>				|  Blank   LineNo Line+>				|  Comment LineNo Line+>+> type LineNo			=  Int+> type Line			=  String++> beginCode, endCode, +>     beginSpec, endSpec	:: Line+> beginCode			=  "\\begin{code}"+> endCode			=  "\\end\&{code}"+> beginSpec			=  "\\begin{spec}"+> endSpec			=  "\\end{spec}"++\NB Damit \verb|"\\end{code}"| nicht das Codesegment beendet, wird ein+Nullstring eingef"ugt: \verb|"\\end\&{code}"|.++> main				:: IO ()+> main				=  do args <- getArgs+>				      unlit args+>+> unlit []			=  getContents       >>= (putStr . convert)+> unlit (filePath : _)		=  readFile filePath >>= (putStr . convert)++Fehlt: Fehlerbehandlung, wenn die Datei nicht vorhanden oder nicht+lesbar ist.++> convert			:: String -> String+> convert			=  lines+>				.> zip [1 ..]		-- number+>				.> map classify+>				.> format+>				.> unlines++> classify			:: (LineNo, Line) -> Class+> classify (n, '>' : s)		=  Program n (' ' : s)+> classify (n, '<' : s)		=  Spec    n (' ' : s)+> classify (n, s)+>     | all isSpace s		=  Blank   n s+> classify (n, s)		=  Comment n s++Die Formatierung wird mit einem einfachen endlichen Automaten mit f"unf+Zust"anden vorgenommen. Es wird darauf geachtet, da"s die Anzahl der+Zeilen nicht ver"andert wird.++> format			:: [Class] -> [Line]+> format []			=  []+> format (Program _ a : x)	=  (beginCode ++ a) : inProgram x+> format (Spec    _ a : x)	=  (beginSpec ++ a) : inSpec    x+> format (Blank   _ a : x)	=                     inBlank a x+> format (Comment _ a : x)	=                 a : inComment x++> inBlank			:: Line -> [Class] -> [Line]+> inBlank a []			=  [a]+> inBlank a (Program _ b : x)	=  beginCode : b : inProgram x+> inBlank a (Spec    _ b : x)	=  beginSpec : b : inSpec    x+> inBlank a (Blank   _ b : x)	=          a :     inBlank b x+> inBlank a (Comment _ b : x)	=          a : b : inComment x++> inProgram			:: [Class] -> [Line]+> inProgram []			=  [ endCode ]+> inProgram (Program _ a : x)	=            a : inProgram x+> inProgram (Spec    n a : x)	=  message n "program line" "specification line"+> inProgram (Blank   _ a : x)	=  endCode     : format    x+> inProgram (Comment n a : x)	=  message n "program line" "comment"++> inSpec			:: [Class] -> [Line]+> inSpec []			=  [ endSpec ]+> inSpec (Program n a : x)	=  message n "specification line" "program line"+> inSpec (Spec    _ a : x)	=            a : inSpec x+> inSpec (Blank   _ a : x)	=  endSpec     : format x+> inSpec (Comment n a : x)	=  message n "specification line" "comment"++> inComment			:: [Class] -> [Line]+> inComment []			=  []+> inComment (Program n a : x)	=  message n "comment" "program line"+> inComment (Spec    n a : x)	=  message n "comment" "specification line"+> inComment (Blank   _ a : x)	=      inBlank   a x+> inComment (Comment _ a : x)	=  a : inComment x++> message			:: LineNo -> String -> String -> a+> message n x y			=  error ("line " ++ show n ++ ": "+>				++ x ++ " next to " ++ y ++ "\n")++\end{document}
+ Examples/UnlitP.lhs view
@@ -0,0 +1,138 @@+% lhs2TeX --poly UnlitP.lhs > UnlitP.tex++\documentclass{article}+\usepackage[german]{babel}++%-------------------------------=  --------------------------------------------++%include lhs2TeX.sty+%include lhs2TeX.fmt++%-------------------------------=  --------------------------------------------++\begin{document}++%-------------------------------=  --------------------------------------------+\section{\texttt{unlit}}+%-------------------------------=  --------------------------------------------++Literate-Skripte, die Bird-Tracks verwenden, in Skripte "uberf"uhren,+die die Pseudo-\TeX-Kommandos \verb|\begin{code}|, \verb|\end{code}|+verwenden. Das Programm realisiert einen einfachen UNIX-Filter.++Synopsis:+%+\begin{verbatim}+unlit+unlit <file>+\end{verbatim}++%-------------------------------=  --------------------------------------------++%if code || showModuleHeader++> module Main			(  main  )+> where+>+> import Char			(  isSpace  )+> import System			(  getArgs  )+> import Auxiliaries		(  (.>)  )++%endif++> data Class			=  Program LineNo Line+>				|  Spec    LineNo Line+>				|  Blank   LineNo Line+>				|  Comment LineNo Line+>+> type LineNo			=  Int+> type Line			=  String++> beginCode, endCode, +>     beginSpec, endSpec	:: Line+> beginCode			=  "\\begin{code}"+> endCode			=  "\\end\&{code}"+> beginSpec			=  "\\begin{spec}"+> endSpec			=  "\\end{spec}"++\NB Damit \verb|"\\end{code}"| nicht das Codesegment beendet, wird ein+Nullstring eingef"ugt: \verb|"\\end\&{code}"|.++> main				:: IO ()+> main				=  do args <- getArgs+>				      unlit args+>+> unlit []			=  getContents       >>= (putStr . convert)+> unlit (filePath : _)		=  readFile filePath >>= (putStr . convert)++Fehlt: Fehlerbehandlung, wenn die Datei nicht vorhanden oder nicht+lesbar ist.++> convert			:: String -> String+> convert			=  lines+>				.> zip [1 ..]		-- number+>				.> map classify+>				.> format+>				.> unlines++> classify			:: (LineNo, Line) -> Class+> classify (n, '>' : s)		=  Program n (' ' : s)+> classify (n, '<' : s)		=  Spec    n (' ' : s)+> classify (n, s)+>     | all isSpace s		=  Blank   n s+> classify (n, s)		=  Comment n s++Die Formatierung wird mit einem einfachen endlichen Automaten mit f"unf+Zust"anden vorgenommen. Es wird darauf geachtet, da"s die Anzahl der+Zeilen nicht ver"andert wird.+\rightcolumn{52}%++> format			:: [Class] -> [Line]+> format []			=  []+> format (Program _ a : x)	=  (beginCode  ++ a) : inProgram x+> format (Spec    _ a : x)	=  (beginSpec  ++ a) : inSpec    x+> format (Blank   _ a : x)	=                      inBlank a x+> format (Comment _ a : x)	=                  a : inComment x++\rightcolumn{45}%+\rightcolumn{37}%++> inBlank			:: Line -> [Class] -> [Line]+> inBlank a []			=  [a]+> inBlank a (Program _ b : x)	=   beginCode  : b : inProgram x+> inBlank a (Spec    _ b : x)	=   beginSpec  : b : inSpec    x+> inBlank a (Blank   _ b : x)	=           a  :     inBlank b x+> inBlank a (Comment _ b : x)	=           a  : b : inComment x++\rightcolumn{45}%+\rightcolumn{37}%++> inProgram			:: [Class] ->  [Line]+> inProgram []			=  [endCode]+> inProgram (Program _  a : x)	=           a : inProgram x+> inProgram (Spec    n  a : x)	=  message n "program line" "specification line"+> inProgram (Blank   _  a : x)	=   endCode   : format    x+> inProgram (Comment n  a : x)	=  message n "program line" "comment"++\rightcolumn{45}%+\rightcolumn{37}%+	+> inSpec			:: [Class] -> [Line]+> inSpec []			=  [endSpec]+> inSpec (Program n  a : x)	=  message n "specification line" "program line"+> inSpec (Spec    _  a : x)	=           a : inSpec x+> inSpec (Blank   _  a : x)	=   endSpec   : format x+> inSpec (Comment n  a : x)	=  message n "specification line" "comment"++> inComment			:: [Class] -> [Line]+> inComment []			=  []+> inComment (Program n  a : x)	=  message n "comment" "program line"+> inComment (Spec    n  a : x)	=  message n "comment" "specification line"+> inComment (Blank   _  a : x)	=      inBlank   a x+> inComment (Comment _  a : x)	=  a : inComment x++> message			:: LineNo -> String -> String -> a+> message n x y			=  error ("line " ++ show n ++ ": "+>				++ x ++ " next to " ++ y ++ "\n")++\end{document}
+ Examples/lhs2TeXpre view
@@ -0,0 +1,18 @@+#! /bin/sh++# wrapper for use with GHC/GHCi+# -pgmF lhs2TeXpre -F++LHSHOME=..++if [ "$1" == "$2" ]; then+  cp "$2" "$3"+else+  if grep -q "^%include" "$1"; then+    TARGET=$3+    # echo Calling with TARGET=${TARGET}+    ${LHSHOME}/lhs2TeX --newcode -P${LHSHOME}: $1 > ${TARGET}+  else+    cp "$2" "$3"+  fi+fi
+ FileNameUtils.lhs view
@@ -0,0 +1,149 @@+> module FileNameUtils          ( extension+>                               , filename+>                               , basename+>                               , dirname+>                               , expandPath+>                               , chaseFile+>                               , modifySearchPath+>                               , deep, absPath, relPath, env+>                               ) where+>+> import Prelude hiding         (  catch )+> import System.IO+> import System.Directory+> import System.Environment+> import Data.List+> import Control.Monad (filterM)+> import Control.Exception      (  try, catch )++> type FileName                 =  String++> directorySeparators           =  "/"+> directorySeparator            =  '/'+> environmentSeparators         =  ";:"++A searchpath can be added to the front or to the back of the current path+by pre- or postfixing it with a path separator. Otherwise the new search+path replaces the current one.++> modifySearchPath              :: [FileName] -> String -> [FileName]+> modifySearchPath p np+>   | any (\x -> x == head np) environmentSeparators = p ++ split+>   | any (\x -> x == last np) environmentSeparators = split ++ p+>   | otherwise                                      = split+>   where split = splitOn environmentSeparators np++> relPath                       :: [String] -> FileName+> relPath ps                    =  concat (intersperse [directorySeparator] ps)++> absPath                       :: [String] -> FileName+> absPath ps                    =  directorySeparator : relPath ps++> isAbsolute                    :: FileName -> Bool+> isAbsolute []                 =  False+> isAbsolute xs                 =  head xs `elem` directorySeparators++> isRelative                    :: FileName -> Bool+> isRelative                    =  not . isAbsolute++> deep                          :: FileName -> FileName+> deep                          =  (++(replicate 2 directorySeparator))++> env                           :: String -> FileName+> env x                         =  "{" ++ x ++ "}"++> extension                     :: FileName -> Maybe String+> extension fn                  =  f False [] fn +>   where+>   f found acc [] | found      =  Just (reverse acc)+>                  | not found  =  Nothing +>   f found acc ('.':cs)        =  f True  []      cs+>   f found acc (c  :cs)        =  f found (c:acc) cs++> dirname                       :: FileName -> String+> dirname fn                    =  f [] [] fn+>   where+>   f res acc []                =  reverse res+>   f res acc (c:cs) +>     | c `elem` directorySeparators +>                               =  f (c : acc ++ res) [] cs+>     | otherwise               =  f res       (c : acc) cs++> filename                      :: FileName -> String+> filename fn                   =  f [] fn +>   where+>   f acc []                    =  reverse acc +>   f acc (c:cs)+>     | c `elem` directorySeparators+>                               =  f []      cs+>     | otherwise               =  f (c:acc) cs++> basename                      :: FileName -> String+> basename fn                   =  takeWhile (/= '.') (filename fn)  ++|expandPath| does two things: it replaces curly braced strings with+environment entries, if present; furthermore, if the path ends with+more than one directory separator, all subpaths are added ...++> expandPath                    :: [String] -> IO [String]+> expandPath s                  =  do let s' = concatMap (splitOn environmentSeparators) s+>                                     s'' <- mapM expandEnvironment s'+>                                     s''' <- mapM findSubPaths (concat s'')+>                                     return (nub $ concat s''')++> findSubPaths                  :: String -> IO [String]+> findSubPaths ""               =  return []+> findSubPaths s                =  let rs = reverse s+>                                      (sep,rs') = span (`elem` directorySeparators) rs+>                                      s'   = reverse rs'+>                                      sep' = reverse sep+>                                  in  if   null s' +>                                      then return [[head sep']] {- we don't descend from root -}+>                                      else if   length sep < 2+>                                           then return [s]+>                                           else descendFrom s'++> descendFrom                   :: String -> IO [String]+> descendFrom s                 =  catch (do  d <- getDirectoryContents s+>                                             {- no hidden files, no parents -}+>                                             let d' = map (\x -> s ++ [directorySeparator] ++ x)+>                                                    . filter ((/='.') . head) . filter (not . null) $ d+>                                             d'' <- filterM doesDirectoryExist d'+>                                             d''' <- mapM descendFrom d''+>                                             return (s : concat d''')+>                                        )+>                                        (const $ return [s])++> expandEnvironment             :: String -> IO [String]+> expandEnvironment s           =  case break (=='{') s of+>                                    (s',"")    -> return [s]+>                                    (s','{':r) -> case break (=='}') r of+>                                                    (e,"") -> return [s]+>                                                    (e,'}':r') -> findEnvironment e s' r'+>   where findEnvironment       :: String -> String -> String -> IO [String]+>         findEnvironment e a o =  do er <- try (getEnv e)+>                                     return $ either (const [])+>                                                     (map (\x -> a ++ x ++ o) . splitOn environmentSeparators)+>                                                     er++> splitOn                       :: String -> String -> [String]+> splitOn b s                   =  case dropWhile (`elem` b) s of+>                                    "" -> []+>                                    s' -> w : splitOn b s''+>                                            where (w,s'') = break (`elem` b) s'++> chaseFile                     :: [String]    {- search path -}+>                               -> FileName -> IO (String,FileName)+> chaseFile p fn | isAbsolute fn=  t fn+>                | p == []      =  chaseFile ["."] fn+>                | otherwise    =  s $ map (\d -> t (md d ++ fn)) p+>   where+>   md cs | last cs `elem` directorySeparators+>                               =  cs+>         | otherwise           =  cs ++ [directorySeparator]+>   t f                         =  catch (readFile f >>= \x -> return (x,f))+>                                        (\_ -> ioError $ userError $ "File `" ++ fn ++ "' not found.\n")+>   s []                        =  ioError +>                               $  userError $ "File `" ++ fn ++ "' not found in search path:\n" ++ showpath+>   s (x:xs)                    =  catch x (\_ -> s xs)+>   showpath                    =  concatMap (\x -> "   " ++ x ++ "\n") p
+ FiniteMap.lhs view
@@ -0,0 +1,77 @@+%-------------------------------=  --------------------------------------------+\subsection{Finite maps}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module FiniteMap              (  FiniteMap, empty, fromList, add, lookup, (!), keys)+> where+> import Prelude hiding         (  lookup  )+> import Data.Maybe++%endif++> type FiniteMap key val        =  Trie key val+>+> data Trie key val             =  Leaf [key] val+>                               |  Node [(key, Trie key val)] (Maybe val)++The value associated with the empty sequence is contained in the |Maybe b|+part. \NB |Node [('a', empty)] Nothing| is not legal.++> empty                         :: Trie key val+> empty                         =  Node [] Nothing+>+> fromList                      :: (Ord key) => [([key], val)] -> Trie key val+> fromList                      =  foldr add empty+>+> add                           :: (Ord a) => ([a], b) -> Trie a b -> Trie a b+> add (x, v) t                  =  insert t x v+>+> lookup                        :: (Ord a) => [a] -> Trie a b -> Maybe b+> lookup x (Leaf y w)+>     | x == y                  =  Just w+>     | otherwise               =  Nothing+> lookup [] (Node ts w)         =  w+> lookup (a : x) (Node ts w)    =  lookupList ts+>     where+>     lookupList []             =  Nothing+>     lookupList ((b, t) : ts)  =  case compare b a of+>         LT                    -> lookupList ts+>         EQ                    -> lookup x t+>         GT                    -> Nothing++> keys                          :: (Ord a) => Trie a b -> [[a]]+> keys                          =  keys' []+>     where+>     keys' acc (Leaf x _)      =  [acc ++ x]+>     keys' acc (Node xs v)     =  maybe [] (const [acc]) v +++>                                  concatMap (\ (x,t) -> keys' (acc ++ [x]) t) xs++Derived functions.++> (!)                           :: (Ord a) => Trie a b -> [a] -> b+> t ! k                         =  fromJust (lookup k t)++Auxiliary functions.+%{+%align 41++> insert                                :: (Ord a) => Trie a b -> [a] -> b -> Trie a b+> insert (Leaf [] _) [] v               =  Leaf [] v+> insert (Leaf (b : y) w) [] v          =  Node [(b, Leaf y w)] (Just v)+> insert (Leaf [] w) (a : x) v          =  Node [(a, Leaf x v)] (Just w)+> insert (Leaf (b : y) w) (a : x) v     =  case compare b a of+>     LT                                -> Node [(b, Leaf y w), (a, Leaf x v)] Nothing+>     EQ                                -> Node [(a, insert (Leaf y w) x v)] Nothing+>     GT                                -> Node [(a, Leaf x v), (b, Leaf y w)] Nothing+> insert (Node ts w) [] v               =  Node ts (Just v)+> insert (Node ts w) (a : x) v          =  Node (insList ts) w+>     where+>     insList []                        =  [(a,Leaf x v)]+>     insList ((b, t) : ts)             =  case compare b a of+>         LT                            -> (b, t) : insList ts+>         EQ                            -> (b, insert t x v) : ts+>         GT                            -> (a, Leaf x v) : (b, t) : ts++%}
+ HsLexer.lhs view
@@ -0,0 +1,341 @@+%-------------------------------=  --------------------------------------------+\subsection{A Haskell lexer}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module HsLexer                (  module HsLexer ) --Token(..), isVarid, isConid, isNotSpace, string, tokenize  )+> where+> import Data.Char 	(  isSpace, isUpper, isLower, isDigit, isAlphaNum  )+> import Control.Monad+> import Document+> import Auxiliaries++%endif+Ein Haskell-Lexer. Modifikation der Prelude-Funktion \hs{lex}.++> data Token                    =  Space String+>                               |  Conid String+>                               |  Varid String+>                               |  Consym String+>                               |  Varsym String+>                               |  Numeral String+>                               |  Char String+>                               |  String String+>                               |  Special Char+>                               |  Comment String+>                               |  Nested String+>                               |  Pragma String+>                               |  Keyword String+>                               |  TeX Doc              -- for inline \TeX+>                               |  Qual [String] Token+>                               |  Op Token+>                                  deriving (Eq, Show)++ks, 03.09.2003: Modified the |Qual| case to contain a list+of strings rather than a single string, to add support for+hierarchical modules. Also added Pragma.++> isVarid, isConid, isNotSpace  :: Token -> Bool+> isVarid (Varid _)             =  True+> isVarid (Qual _ t)            =  isVarid t+> isVarid _                     =  False+>+> isConid (Conid _)             =  True+> isConid (Qual _ t)            =  isConid t+> isConid _                     =  False+>+> isNotSpace (Space _)          =  False+> isNotSpace _                  =  True++> string                        :: Token -> String+> string (Space s)              =  s+> string (Conid s)              =  s+> string (Varid s)              =  s+> string (Consym s)             =  s+> string (Varsym s)             =  s+> string (Numeral s)            =  s+> string (Char s)               =  s+> string (String s)             =  s+> string (Special c)            =  [c]+> string (Comment s)            =  "--" ++ s+> string (Nested s)             =  "{-" ++ s ++ "-}"+> string (Pragma s)             =  "{-#" ++ s ++ "#-}"+> string (Keyword s)            =  s+> string (TeX (Text s))         =  "{-\"" ++ s ++ "\"-}"++This change is by ks, 14.05.2003, to make the @poly@ formatter work.+This should probably be either documented better or be removed again.++> string (TeX _)                =  "" -- |impossible "string"|+> string (Qual m s)             =  concatMap (++".") m ++ string s+> string (Op s)                 =  "`" ++ string s ++ "`"++> tokenize                      :: [Char] -> Either Exc [Token]+> tokenize                      =  lift tidyup @@ lift qualify @@ lexify++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Phase 1}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++%{+%format lex' = "\Varid{lex}"++> lexify                        :: [Char] -> Either Exc [Token]+> lexify []                     =  return []+> lexify s@(_ : _)              =  case lex' s of+>     Nothing                   -> Left ("lexical error", s)+>     Just (t, s')              -> do ts <- lexify s'; return (t : ts)+>+> lex'                          :: String -> Maybe (Token, String)+> lex' ""                       =  Nothing+> lex' ('\'' : s)               =  do let (t, u) = lexLitChar s+>                                     v <- match "\'" u+>                                     return (Char ("'" ++ t ++ "'"), v)+> lex' ('"' : s)                =  do let (t, u) = lexLitStr s+>                                     v <- match "\"" u+>                                     return (String ("\"" ++ t ++ "\""), v)+> lex' ('-' : '-' : s)          =  let (t, u) = break (== '\n') s+>                                  in  return (Comment t, u)+> lex' ('{' : '-' : '"' : s)    =  do let (t, u) = inlineTeX s+>                                     v <- match "\"-}" u+>                                     return (TeX (Text t), v)+> lex' ('{' : '-' : '#' : s)    =  do let (t, u) = nested 0 s+>                                     v <- match "#-}" u+>                                     return (Pragma t, v)+> lex' ('{' : '-' : s)          =  do let (t, u) = nested 0 s+>                                     v <- match "-}" u+>                                     return (Nested t, v)+> lex' (c : s)+>     | isSpace c               =  let (t, u) = span isSpace s in return (Space (c : t), u)+>     | isSpecial c             =  Just (Special c, s)+>     | isUpper c               =  let (t, u) = span isIdChar s in return (Conid (c : t), u)+>     | isLower c || c == '_'   =  let (t, u) = span isIdChar s in return (classify (c : t), u)+>     | c == ':'                =  let (t, u) = span isSymbol s in return (Consym (c : t), u)+>     | isSymbol c              =  let (t, u) = span isSymbol s in return (Varsym (c : t), u)+>     | isDigit c               =  do let (ds, t) = span isDigit s+>                                     (fe, u)  <- lexFracExp t+>                                     return (Numeral (c : ds ++ fe), u)+>     | otherwise               =  Nothing+>     where+>     classify s+>         | s `elem` keywords   =  Keyword s+>         | otherwise           =  Varid   s+>+>+> lexFracExp                    :: String -> Maybe (String, String)+> lexFracExp s                  =  do t <- match "." s+>                                     (ds, u) <- lexDigits' t+>                                     (e, v)  <- lexExp u+>                                     return ('.' : ds ++ e, v)+>                               `mplus` Just ("", s)+>+> lexExp                        :: String -> Maybe (String, String)+> lexExp (e:s)+>      | e `elem` "eE"          =  do (c : t) <- Just s+>                                     if c `elem` "+-" then return () else Nothing+>                                     (ds, u) <- lexDigits' t+>                                     return (e : c : ds, u)+>                               `mplus` do (ds, t) <- lexDigits' s+>                                          return (e : ds, t)+> lexExp s                      =  Just ("", s)+>+> lexDigits'                    :: String -> Maybe (String, String)+> lexDigits' s                  =  do (cs@(_ : _), t) <- Just (span isDigit s); return (cs, t)++%}++\NB `@'@' serves as an escape symbol in inline \TeX.++> inlineTeX                     :: String -> (String, String)+> inlineTeX []                  =  ([], [])+> inlineTeX ('\'' : 'n' : s)    =  '\n' <| inlineTeX s+> inlineTeX ('\'' : 'd' : s)    =  '"' <| inlineTeX s -- added 18.03.2001+> inlineTeX ('\'' : c : s)      =  c <| inlineTeX s+> inlineTeX ('"' : s)           =  ([], '"' : s)+> inlineTeX (c : s)             =  c <| inlineTeX s+>+> nested                        :: Int -> String -> (String, String)+> nested _     []               =  ([], [])+> nested 0     ('#' : '-' : '}' : s)+>                               =  ([], '#':'-':'}':s)+> nested 0     ('-' : '}' : s)  =  ([], '-':'}':s)+> nested (n+1) ('-' : '}' : s)  =  '-' <| '}' <| nested n s+> nested n     ('{' : '-' : s)  =  '{' <| '-' <| nested (n + 1) s+> nested n     (c : s)          =  c <| nested n s++ks, 03.09.2003: The above definition of nested will actually+incorrectly reject programs that contain comments like the+following one: {- start normal, but close as pragma #-} ...+I don't expect this to be a problem, though.++\NB GHC meldet bei |nested| f"alschlicherweise "`incomplete+patterns"'. [ks: This is no longer true (with GHC 5.04.3).]++> lexLitChar, lexLitStr         :: String -> (String, String)+> lexLitChar []                 =  ([], [])+> lexLitChar ('\'' : s)         =  ([], '\'' : s)+> lexLitChar ('\\' : c : s)     =  '\\' <| c <| lexLitChar s+> lexLitChar (c : s)            =  c <| lexLitChar s+>+> lexLitStr []                  =  ([], [])+> lexLitStr ('"' : s)           =  ([], '"' : s)+> lexLitStr ('\\' : c : s)      =  '\\' <| c <| lexLitStr s+> lexLitStr (c : s)             =  c <| lexLitStr s++> isSpecial, isSymbol, isIdChar :: Char -> Bool+> isSpecial c                   =  c `elem` ",;()[]{}`"+> isSymbol c                    =  c `elem` "!@#$%&*+./<=>?\\^|:-~"+> isIdChar c                    =  isAlphaNum c || c `elem` "_'"++> match                         :: String -> String -> Maybe String+> match p s+>     | p == t                  =  Just u+>     | otherwise               =  Nothing+>     where (t, u)              =  splitAt (length p) s++\NB |match| entspricht eigentlich |lits|.++Schl"usselw"orter.++> keywords                      :: [String]+> keywords                      =  [ "case",     "class",    "data",  "default",+>                                    "deriving", "do",       "else",  "if",+>                                    "import",   "in",       "infix", "infixl",+>                                    "infixr",   "instance", "let",   "module",+>                                    "newtype",  "of",       "then",  "type",+>                                    "where" ]++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Phase 2}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Zusammenf"ugen von qualifizierten Namen.+ks, 27.06.2003: I have modified the fifth case of |qualify|+to only match if the |Varsym| contains at least one symbol+besides the dot. Otherwise the dot is an operator, not part+of a qualified name.+ks, 03.09.2003: Deal with hierarchical module names. This could+be made more efficient if that seems necessary.++> qualify                       :: [Token] -> [Token]+> qualify []                    =  []+> qualify (Conid m :  Varsym "." : t@(Conid _) : ts)+>                               =  qualify (Qual [m] t : ts)+> qualify (Conid m :  Varsym "." : t@(Varid _) : ts)+>                               =  Qual [m] t : qualify ts+> qualify (Conid m : Varsym ('.' : s@(':' : _)) : ts)+>                               =  Qual [m] (Consym s) : qualify ts+> qualify (Conid m : Varsym ('.' : s@(_ : _)) : ts)+>                               =  Qual [m] (Varsym s) : qualify ts+> qualify (Qual m (Conid m') : Varsym "." : t@(Conid _) : ts)+>                               =  qualify (Qual (m ++ [m']) t : qualify ts)+> qualify (Qual m (Conid m') : Varsym "." : t@(Varid _) : ts)+>                               =  Qual (m ++ [m']) t : qualify ts+> qualify (Qual m (Conid m') : Varsym ('.' : s@(':' : _)) : ts)+>                               =  Qual (m ++ [m']) (Consym s) : qualify ts+> qualify (Qual m (Conid m') : Varsym ('.' : s@(_ : _)) : ts)+>                               =  Qual (m ++ [m']) (Varsym s) : qualify ts+> qualify (t : ts)              =  t : qualify ts++Backquoted ids zusammenfassen, da @`Prelude.div`@ zul"assig ist,+erst nach |qualify|.++> tidyup                        :: [Token] -> [Token]+> tidyup []                     =  []+> tidyup (Special '`' : t@(Varid _) : Special '`' : ts)+>                               =  Op t : tidyup ts+> tidyup (Special '`' : t@(Conid _) : Special '`' : ts)+>                               =  Op t : tidyup ts+> tidyup (Special '`' : t@(Qual _ (Varid _)) : Special '`' : ts)+>                               =  Op t : tidyup ts+> tidyup (Special '`' : t@(Qual _ (Conid _)) : Special '`' : ts)+>                               =  Op t : tidyup ts+> tidyup (String s : ts)        =  strItems s ++ tidyup ts+> tidyup (Space s : ts)         =  splitSpace s ++ tidyup ts+> tidyup (t : ts)               =  t : tidyup ts++Beachte: @` div `@ wird nicht zusammengefa"st; damit wird eine+eventuelle Formatanweisung @%format `div` = ...@ ignoriert.++Breaking a string into string items.++> strItems                      :: String -> [Token]+> strItems []                   =  impossible "strItems"+> strItems (c : s)              =  case breaks isGap s of+>     (item, '\\' : s')         -> String (c : item ++ "\\") : Space white : strItems rest+>         where (white, rest)   =  span isSpace s'+>     _                         -> [String (c : s)]+>+> isGap                         :: String -> Bool+> isGap ('\\' : '\n' : _)       =  True+> isGap _                       =  False++ks, 12.01.2004: changed the definition of |isGap| to be |True|+only if the character following a backslash is a newline. Otherwise,+the sequence |"\\ "| will be incorrectly treated as a string gap.+I am not convinced that the special treatment of string gaps is a+good thing at all. String gaps don't work in newcode style, as it+is right now.++> splitSpace                    :: String -> [Token]+> splitSpace []                 =  []+> splitSpace s                  =  Space t : splitSpace u+>     where (t, u)              =  breakAfter (== '\n') s++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{A token class}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++We distinguish between white space, separators, delimiters and+non-separators.++> data CatCode                  =  White+>                               |  Sep+>                               |  Del Char+>                               |  NoSep+>                                  deriving (Eq)++\Todo{Is the class |CToken| still necessary?}++> class CToken tok where+>     catCode                   :: tok -> CatCode+>     token                     :: tok -> Token+>     inherit                   :: tok -> Token -> tok+>     fromToken                 :: Token -> tok++|inherit old t| adds |old|'s attributes (eg positional information) to+|t|.++> instance CToken Token where+>     catCode (Space _)         =  White+>     catCode (Conid _)         =  NoSep+>     catCode (Varid _)         =  NoSep+>     catCode (Consym _)        =  Sep+>     catCode (Varsym _)        =  Sep+>     catCode (Numeral _)       =  NoSep+>     catCode (Char _)          =  NoSep+>     catCode (String _)        =  NoSep+>     catCode (Special c)+>         | c `elem` "([])"     =  Del c+>         | otherwise           =  Sep++\NB Only @([])@ are classified as delimiters; @{}@ are separators since+they do not bracket expressions.++>     catCode (Comment _)       =  White+>     catCode (Nested _)        =  White+>     catCode (Pragma _)        =  White+>     catCode (Keyword _)       =  Sep+>     catCode (TeX (Text _))    =  White++The following change is by ks, 14.05.2003.+This is related to the change above in function |string|.++>     catCode (TeX _)           =  NoSep -- |impossible "catCode"|+>     catCode (Qual _ t)        =  catCode t+>     catCode (Op _)            =  Sep+>     token                     =  id+>     inherit _ t               =  t+>     fromToken                 =  id+
+ INSTALL view
@@ -0,0 +1,98 @@+There are two possibilities to install lhs2TeX:++(A) Using Cabal.+(B) Classic configure/make.++=====================================================================++(A) Using Cabal to install lhs2TeX:++This requires Cabal 1.1.6 or later. The process is then as usual:++runghc Setup configure+runghc Setup build+runghc Setup install++The third step requires write access to the installation location and+the LaTeX filename database.++=====================================================================++(B) configure/make:++The following instructions apply to Unix-like environments.  However,+lhs2TeX does run on Windows systems, too. (If you would like to add+installation instructions or facilitate the installation procedure for+Windows systems, please contact the authors.)++Unpack the archive. Assume that it has been unpacked into directory+"/somewhere". Then say++cd /somewhere/lhs2TeX-1.12+./configure+make+make install++You might need administrator permissions to perform the "make install"+step. Alternatively, you can select your own installation location by+passing the "--prefix" argument to @configure@:++./configure --prefix=/my/local/programs++With lhs2TeX come a couple of library files (containing basic+lhs2TeX formatting directives) that need to be found by the+lhs2TeX binary. The default search path is as follows:++.+{HOME}/lhs2tex-1.12//+{HOME}/lhs2tex//+{HOME}/lhs2TeX//+{HOME}/.lhs2tex-1.12//+{HOME}/.lhs2tex//+{HOME}/.lhs2TeX//+{LHS2TEX}//+/usr/local/share/lhs2tex-1.12//+/usr/local/share/lhs2tex-1.12//+/usr/local/lib/lhs2tex-1.12//+/usr/share/lhs2tex-1.12//+/usr/lib/lhs2tex-1.12//+/usr/local/share/lhs2tex//+/usr/local/share/lhs2tex//+/usr/local/lib/lhs2tex//+/usr/share/lhs2tex//+/usr/lib/lhs2tex//+/usr/local/share/lhs2TeX//+/usr/local/share/lhs2TeX//+/usr/local/lib/lhs2TeX//+/usr/share/lhs2TeX//+/usr/lib/lhs2TeX//++Here, {HOME} and {LHS2TEX} denote the current values of these two+environment variables HOME and LHS2TEX. The double slash at the end of+each dir means that subdirectories are also scanned. If lhs2TeX is+installed to a non-standard path, you might want to set the+environment variable "LHS2TEX" to point to the directory where+"lhs2TeX.fmt" and the other library files have been installed to.++IMPORTANT:+To be able to use ``poly'' style, the two LaTeX +packages "polytable.sty" and "lazylist.sty" are required!++Both are included in the lhs2TeX distribution (they are not part of+standard LaTeX distributions, although they are available from+CTAN), and are usually installed during the normal procedure. The+configure script will determine whether a suitably recent version of+polytable is installed on your system, and if necessary, install+both "polytable.sty" and "lazylist.sty" to your TeX system. If this+is not desired or fails (because the script cannot detect your TeX+installation properly), the installation of these files can be+disabled by passing the option "--disable-polytable" to+"configure". In this case, the two files must be manually installed to+a location where your TeX distribution will find them.  Assuming+that you have a local TeX tree at "/usr/local/share/texmf", this can+usually be avhieved by placing the files in the directory+"/usr/local/share/texmf/tex/latex/polytable" and subsequently running++mktexlsr ++to update the TeX filename database.
+ LICENSE view
@@ -0,0 +1,22 @@+Copyright (c) 1997-2005 Ralf Hinze, Andres Loeh++This package is free software; you can redistribute it and/or modify+it under the terms of the GNU General Public License as published by+the Free Software Foundation; either version 2 of the License, or+(at your option) any later version.++As a special exception, permission is granted to include the files+(or parts of the files) lhs2TeX.sty, lhs2TeX.fmt, as well as files +(or parts of files) distributed in the Library subdirectory of this +package that include a notice in their header, literally in other +documents, regardless of the conditions or license applying to these +documents.++This package is distributed in the hope that it will be useful,+but WITHOUT ANY WARRANTY; without even the implied warranty of+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the+GNU General Public License for more details.+ +You should have received a copy of the GNU General Public License+along with this program; if not, write to the Free Software+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Library/colorcode.fmt view
@@ -0,0 +1,65 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% colorcode.fmt+%+% code in a colored box for poly style in lhs2TeX;+% very experimental+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, November 2005, ver 1.6+%+% TODO: fix spacing behaviour for other environments+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_colorcode_fmt_read+%let lhs2tex_colorcode_fmt_read = True+%include polycode.fmt+%+%if style /= newcode+\ReadOnlyOnce{colorcode.fmt}%++\RequirePackage{colortbl}+\RequirePackage{calc}++% The color environment displays each code block in a colored box.++\makeatletter+\newenvironment{colorhscode}%+  {{\parskip=0pt\parindent=0pt\par\vskip\abovedisplayskip\noindent}%+   \hscodestyle+   \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+   \let\\=\@@normalcr+   \(\pboxed}%+  {\endpboxed\)%+   \endtabular+   {\parskip=0pt\parindent=0pt\par\vskip\belowdisplayskip\noindent}%+   \ignorespacesafterend}++\newenvironment{barhscode}%+  {\hsnewpar\abovedisplayskip+   \hscodestyle+   \arrayrulecolor{codecolor}%+   \arrayrulewidth=\coderulewidth+   \tabular{||p{\linewidth-\arrayrulewidth-\tabcolsep}@@{}}%+   \let\\=\@@normalcr+   \(\pboxed}%+  {\endpboxed\)%+   \endtabular+   \hsnewpar\belowdisplayskip+   \ignorespacesafterend}+\makeatother++\def\colorcode{\columncolor{codecolor}}+\definecolor{codecolor}{rgb}{1,1,.667}+\newlength{\coderulewidth}+\setlength{\coderulewidth}{3pt}++\newcommand{\colorhs}{\sethscode{colorhscode}}+\newcommand{\barhs}{\sethscode{barhscode}}++\EndFmtInput+%endif+%endif
+ Library/forall.fmt view
@@ -0,0 +1,65 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% forall.fmt+%+% *EXPERIMENTAL*+% Semi-automatic formatting of the . as either function+% composition (normally) or a period (when used after a+% forall).+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, November 2005, ver 1.1+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_forall_fmt_read+%let lhs2tex_forall_fmt_read = True+%include lhs2TeX.fmt+%+%if style /= newcode+%+% First, let's redefine the forall, and the dot.+%+%format forall(x) = forall_ x "\hsforall "+%format .         = "\hsdot{" `comp_` "}{" period_ "}"+%format `comp_`   = "\circ "+%format period_   = "."+%format forall_   = "\forall "+%+% This is made in such a way that after a forall, the next+% dot will be printed as a period, otherwise the formatting+% of `comp_` is used. By redefining `comp_`, as suitable+% composition operator can be chosen. Similarly, period_+% is used for the period.+%+\ReadOnlyOnce{forall.fmt}%+\makeatletter++% The HaskellResetHook is a list to which things can+% be added that reset the Haskell state to the beginning.+% This is to recover from states where the hacked intelligence+% is not sufficient.++\let\HaskellResetHook\empty+\newcommand*{\AtHaskellReset}[1]{%+  \g@@addto@@macro\HaskellResetHook{#1}}+\newcommand*{\HaskellReset}{\HaskellResetHook}++\global\let\hsforallread\empty++\newcommand\hsforall{\global\let\hsdot=\hsperiodonce}+\newcommand*\hsperiodonce[2]{#2\global\let\hsdot=\hscompose}+\newcommand*\hscompose[2]{#1}++\AtHaskellReset{\global\let\hsdot=\hscompose}++% In the beginning, we should reset Haskell once.+\HaskellReset++\makeatother+\EndFmtInput+%endif+%endif
+ Library/greek.fmt view
@@ -0,0 +1,67 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% greek.fmt+%+% Formatting of Greek characters.+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, November 2005, ver 1.1+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_greek_fmt_read+%let lhs2tex_greek_fmt_read = True+%+%if style == poly+%format alpha   = "\alpha "+%format beta    = "\beta "+%format gamma   = "\gamma "+%format delta   = "\delta "+%format epsilon = "\varepsilon "+%format zeta    = "\zeta "+%format eta     = "\eta "+%format theta   = "\vartheta "+%format iota    = "\iota "+%format kappa   = "\kappa "+%format lambda  = "\lambda "+%format mu      = "\mu "+%format nu      = "\nu "+%format omikron = "o"+%format pi      = "\pi "+%format rho     = "\rho "+%format sigma   = "\sigma "+%format tau     = "\tau "+%format upsilon = "\upsilon "+%format phi     = "\varphi "+%format chi     = "\chi "+%format psi     = "\psi "+%format omega   = "\omega "+%format Alpha   = "\mathrm{A}"+%format Beta    = "\mathrm{B}"+%format Gamma   = "\Gamma "+%format Delta   = "\Delta "+%format Epsilon = "\mathrm{E}"+%format Zeta    = "\mathrm{Z}"+%format Eta     = "\mathrm{H}"+%format Theta   = "\Theta "+%format Iota    = "\mathrm{I}"+%format Kappa   = "\mathrm{K}"+%format Lambda  = "\Lambda "+%format Mu      = "\mathrm{M}"+%format Nu      = "\mathrm{N}"+%format Xi      = "\Xi "+%format Omikron = "\mathrm{O}"+%format Pi      = "\Pi "+%format Rho     = "\mathrm{P}"+%format Sigma   = "\Sigma "+%format Tau     = "\mathrm{T}"+%format Upsilon = "\Upsilon "+%format Phi     = "\Phi "+%format Chi     = "\mathrm{X}"+%format Psi     = "\Psi "+%format Omega   = "\Omega "+%endif+%endif
+ Library/jfpcompat.fmt view
@@ -0,0 +1,35 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% jfpcompat.fmt+%+% jfp.cls is incompatible with array.sty! This is a fix.+% This is included in the lhs2TeX distribution because+% lhs2TeX depends on array.sty, and many lhs2TeX users are+% JFP authors.+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, November 2005, ver 1.1+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_jfpcompat_fmt_read+%let lhs2tex_jfpcompat_fmt_read = True+%include lhs2TeX.fmt+% +\ReadOnlyOnce{jfpcompat.fmt}%+\makeatletter+\def\@@authortable{%+  \leavevmode \hbox \bgroup $\col@@sep\tabcolsep+  \let\d@@llarbegin\begingroup+  \let\d@@llarend\endgroup+  \let\\\author@@tabcrone+  \ignorespaces+  \@@tabarray}++\makeatother+\EndFmtInput+%+%endif
+ Library/polycode.fmt view
@@ -0,0 +1,182 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% polycode.fmt+%+% better code environment for poly style in lhs2TeX+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, February 2006, ver 1.9+%+% TODO: use \[ \] in arrayhs (fleqn problem)+%       think about penalties and better pagebreaks+%         by using \allowdisplaybreaks+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_polycode_fmt_read+%let lhs2tex_polycode_fmt_read = True+%include lhs2TeX.fmt+%+%if style /= newcode+%+%if False+% The follwing subst replaces the bad default from lhs2TeX.fmt.+% The idea is to just provide the basic structure in the subst, and+% let the rest be handled by a LaTeX environment.+%endif+%+%subst code a = "\begin{hscode}\SaveRestoreHook'n" a "\ColumnHook'n\end{hscode}\resethooks'n"+%+%+% This package provides two environments suitable to take the place+% of hscode, called "plainhscode" and "arrayhscode". +%+% The plain environment surrounds each code block by vertical space,+% and it uses \abovedisplayskip and \belowdisplayskip to get spacing+% similar to formulas. Note that if these dimensions are changed,+% the spacing around displayed math formulas changes as well.+% All code is indented using \leftskip.+%+% Changed 19.08.2004 to reflect changes in colorcode. Should work with+% CodeGroup.sty.+%+\ReadOnlyOnce{polycode.fmt}%+\makeatletter++\newcommand{\hsnewpar}[1]%+  {{\parskip=0pt\parindent=0pt\par\vskip #1\noindent}}++% can be used, for instance, to redefine the code size, by setting the+% command to \small or something alike+\newcommand{\hscodestyle}{}++% The command \sethscode can be used to switch the code formatting+% behaviour by mapping the hscode environment in the subst directive+% to a new LaTeX environment.++\newcommand{\sethscode}[1]%+  {\expandafter\let\expandafter\hscode\csname #1\endcsname+   \expandafter\let\expandafter\endhscode\csname end#1\endcsname}++% "compatibility" mode restores the non-polycode.fmt layout.++\newenvironment{compathscode}%+  {\par\noindent+   \advance\leftskip\mathindent+   \hscodestyle+   \let\\=\@@normalcr+   \(\pboxed}%+  {\endpboxed\)%+   \par\noindent+   \ignorespacesafterend}++\newcommand{\compaths}{\sethscode{compathscode}}++% "plain" mode is the proposed default.++\newenvironment{plainhscode}%+  {\hsnewpar\abovedisplayskip+   \advance\leftskip\mathindent+   \hscodestyle+   \let\\=\@@normalcr+   \(\pboxed}%+  {\endpboxed\)%+   \hsnewpar\belowdisplayskip+   \ignorespacesafterend}++% Here, we make plainhscode the default environment.++\newcommand{\plainhs}{\sethscode{plainhscode}}+\plainhs++% The arrayhscode is like plain, but makes use of polytable's+% parray environment which disallows page breaks in code blocks.++\newenvironment{arrayhscode}%+  {\hsnewpar\abovedisplayskip+   \advance\leftskip\mathindent+   \hscodestyle+   \let\\=\@@normalcr+   \(\parray}%+  {\endparray\)%+   \hsnewpar\belowdisplayskip+   \ignorespacesafterend}++\newcommand{\arrayhs}{\sethscode{arrayhscode}}++% The mathhscode environment also makes use of polytable's parray +% environment. It is supposed to be used only inside math mode +% (I used it to typeset the type rules in my thesis).++\newenvironment{mathhscode}%+  {\parray}{\endparray}++\newcommand{\mathhs}{\sethscode{mathhscode}}++% texths is similar to mathhs, but works in text mode.++\newenvironment{texthscode}%+  {\(\parray}{\endparray\)}++\newcommand{\texths}{\sethscode{texthscode}}++% The framed environment places code in a framed box.++\def\codeframewidth{\arrayrulewidth}+\RequirePackage{calc}++\newenvironment{framedhscode}%+  {\parskip=\abovedisplayskip\par\noindent+   \hscodestyle+   \arrayrulewidth=\codeframewidth+   \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%+   \hline\framedhslinecorrect\\{-1.5ex}%+   \let\endoflinesave=\\+   \let\\=\@@normalcr+   \(\pboxed}%+  {\endpboxed\)%+   \framedhslinecorrect\endoflinesave{.5ex}\hline+   \endtabular+   \parskip=\belowdisplayskip\par\noindent+   \ignorespacesafterend}++\newcommand{\framedhslinecorrect}[2]%+  {#1[#2]}++\newcommand{\framedhs}{\sethscode{framedhscode}}++% The inlinehscode environment is an experimental environment+% that can be used to typeset displayed code inline.++\newenvironment{inlinehscode}%+  {\(\def\column##1##2{}%+   \let\>\undefined\let\<\undefined\let\\\undefined+   \newcommand\>[1][]{}\newcommand\<[1][]{}\newcommand\\[1][]{}%+   \def\fromto##1##2##3{##3}%+   \def\nextline{}}{\) }%++\newcommand{\inlinehs}{\sethscode{inlinehscode}}++% The joincode environment is a separate environment that+% can be used to surround and thereby connect multiple code+% blocks.++\newenvironment{joincode}%+  {\let\orighscode=\hscode+   \let\origendhscode=\endhscode+   \def\endhscode{\def\hscode{\endgroup\def\@@currenvir{hscode}\\}\begingroup}+   %\let\SaveRestoreHook=\empty+   %\let\ColumnHook=\empty+   %\let\resethooks=\empty+   \orighscode\def\hscode{\endgroup\def\@@currenvir{hscode}}}%+  {\origendhscode+   \global\let\hscode=\orighscode+   \global\let\endhscode=\origendhscode}%++\makeatother+\EndFmtInput+%+%endif+%endif
+ Library/spacing.fmt view
@@ -0,0 +1,36 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% spacing.fmt+%+% Formatting sequences of ^ as spaces of different width.+% Note that the default formatting of (^) is affected by this.+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, November 2005, ver 1.1+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_spacing_fmt_read+%let lhs2tex_spacing_fmt_read = True+%+%if style == newcode++%format ^ =+%format ^^ = " "+%format ^^^ = "  "+%format ^^^^ = "   "+%format ^^. =++%else++%format ^ = " "+%format ^^ = "\;"+%format ^^^ = "\quad "+%format ^^^^ = "\qquad "+%format ^^. = ^^ "."++%endif+%endif
+ Main.lhs view
@@ -0,0 +1,986 @@+%-------------------------------=  --------------------------------------------+\subsection{Main program}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Main ( main )+> where+>+> import Data.Char ( isSpace )+> import System.IO ( hClose, hPutStr, hPutStrLn, hFlush, hGetLine, stderr, stdout, openFile, IOMode(..), Handle(..) )+> import System.Directory ( copyFile )+> import System.Console.GetOpt+> import Text.Regex ( matchRegex, mkRegexWithOpts )+> import System.Environment+> import System.Exit+> import System.Process+> import Version+> import Control.Monad+>+> -- import IOExts+> import TeXCommands+> import TeXParser+> import qualified Verbatim+> import qualified Typewriter+> import qualified Math+> import qualified MathPoly as Poly+> import qualified NewCode+> import Directives+> import Document+> import StateT+> import qualified FiniteMap as FM+> import Auxiliaries+> import Value+>+> import FileNameUtils+> --import Directory++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Main loop}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> main                          :: IO ()+> main                          =  getArgs >>= main'++> main'                         :: [String] -> IO ()+> main' args                    =  case getOpt Permute options args of+>   (o,n,[])                    -> do (flags,initdirs,styles) +>                                        <- foldM (\(s,d,x) (sf,df,ns) -> do s' <- sf s+>                                                                            return (s',df d,ns ++ x))+>                                                 (state0,[],[]) o+>                                     case reverse styles of+>                                       []  -> lhs2TeX Poly flags (reverse initdirs) n+>                                           -- ks, 22.11.2005, changed default style to |Poly|+>                                       [Help]        -> quitSuccess (usageInfo uheader options)+>                                       [SearchPath]  -> quitSuccess (init . unlines $ searchPath)+>                                       [Version]     -> quitSuccess programInfo+>                                       [Copying]     -> quitSuccess (programInfo ++ "\n\n" ++ copying)+>                                       [Warranty]    -> quitSuccess (programInfo ++ "\n\n" ++ warranty)+>                                       [Pre] | length n >= 3 -> preprocess flags (reverse initdirs) False n  -- used as preprocessor -pgmF -F+>                                       [Pre,Help] | length n >= 3 -> preprocess flags (reverse initdirs) True n  -- used as literate preprocessor -pgmL+>                                       [s]    -> lhs2TeX s flags (reverse initdirs) n+>                                       _      -> quitError (incompatibleStylesError styles)+>                                     when (output flags /= stdout) (hClose (output flags))+>   (_,_,errs)                  -> do hPutStrLn stderr $ (concat errs)+>                                     hPutStrLn stderr $ "Trying compatibility mode option handling ..."+>                                     cstyle args+>  where+>    quitSuccess s              =  do hPutStrLn stdout $ s+>                                     exitWith ExitSuccess+>    quitError s                =  do hPutStrLn stderr $ usageInfo (s ++ "\n" ++ uheader) options+>                                     exitFailure+>    incompatibleStylesError ss =  "only one style allowed from: "+>                                     ++ unwords (map (\s -> "--" ++ decode s) ss) ++ "\n"++> type Formatter                =  XIO Exc State ()++State.++> type CondInfo                 =  (FilePath, LineNo, Bool, Bool)++> data State                    =  State { style      :: Style,+>                                          verbose    :: Bool,+>                                          searchpath :: [FilePath],+>                                          file       :: FilePath,      -- also used for `hugs'+>                                          lineno     :: LineNo,+>                                          ofile      :: FilePath,+>                                          olineno    :: LineNo,+>                                          atnewline  :: Bool,+>                                          fldir      :: Bool,          -- file/linenumber directives+>                                          output     :: Handle,+>                                          opts       :: String,        -- options for `hugs'+>                                          files      :: [(FilePath, LineNo)], -- includees (?)+>                                          path       :: FilePath,      -- for relative includes+>                                          fmts       :: Formats,+>                                          subst      :: Substs,+>                                          stack      :: [Formats],     -- for grouping+>                                          toggles    :: Toggles,       -- @%let@ defined toggles+>                                          conds      :: [CondInfo],    -- for conditional directives+>                                          align      :: Maybe Int,     -- math: internal alignment column+>                                          stacks     :: (Math.Stack, Math.Stack),      -- math: indentation stacks+>                                          separation :: Int,           -- poly: separation+>                                          latency    :: Int,           -- poly: latency+>                                          pstack     :: Poly.Stack,    -- poly: indentation stack+>                                          externals  :: Externals      -- handles for external processes (hugs,ghci)+>                                        }++Initial state.++> state0                        :: State+> state0                        =  State { verbose    = False,+>                                          searchpath = searchPath,+>                                          lineno     = 0,+>                                          olineno    = 0,+>                                          atnewline  = True,+>                                          fldir      = False,+>                                          output     = stdout,+>                                          opts       = "",+>                                          files      = [],+>                                          path       = "",+>                                          fmts       = FM.empty,+>                                          subst      = FM.empty,+>                                          stack      = [],+>                                          conds      = [],+>                                          align      = Nothing,+>                                          stacks     = ([], []),+>                                          separation = 2,+>                                          latency    = 2,+>                                          pstack     = [],+>                                          -- ks, 03.01.04: added to prevent warnings during compilation+>                                          style      = error "uninitialized style",+>                                          file       = error "uninitialized filename",+>                                          ofile      = error "uninitialized filename",+>                                          toggles    = error "uninitialized toggles",+>                                          externals  = FM.empty+>                                        }++> initState                     :: Style -> FilePath -> [FilePath] -> State -> State+> initState sty filePath ep s   =  s { style = sty, +>                                      file = filePath,+>                                      ofile = filePath,+>                                      searchpath = ep,+>                                      toggles = FM.fromList toggles0 +>                                    }+>     where toggles0            =  --[(decode CodeOnly, Bool (sty == CodeOnly))]+>                                  [("style", Int (fromEnum sty))]+>                               ++ [("version", Int numversion)]+>                               ++ [("pre", Int pre)]+>                               ++ [ (decode s, Int (fromEnum s)) | s <- [(minBound :: Style) .. maxBound] ]+>                               -- |++ [ (s, Bool False) || s <- ["underlineKeywords", "spacePreserving", "meta", "array", "latex209", "times", "euler" ] ]|++> preprocess                    :: State -> [Class] -> Bool -> [String] -> IO ()+> preprocess flags dirs lit (f1:f2:f3:_)+>                               =  if (f1 == f2) && not lit+>                                  then copyFile f2 f3+>                                  else do c <- readFile f1+>                                          case matchRegex (mkRegexWithOpts "^%include" True False) c of+>                                            Nothing -> if lit then+>                                                          do h <- openFile f3 WriteMode+>                                                             lhs2TeX NewCode (flags { output = h }) (Directive Include "lhs2TeX.fmt" : dirs) [f1]+>                                                             hClose h+>                                                       else copyFile f2 f3+>                                            Just _  -> -- supposed to be an lhs2TeX file+>                                                       do h <- openFile f3 WriteMode+>                                                          lhs2TeX NewCode (flags { output = h }) dirs [f1]+>                                                          hClose h+> preprocess _ _ _ _            =  error "preprocess: too few arguments"++> lhs2TeX                       :: Style -> State -> [Class] -> [String] -> IO ()+> lhs2TeX s flags dirs files    =  do (str, file) <- input files+>                                     expandedpath <- expandPath (searchpath flags)+>                                     toIO (do store (initState s file expandedpath flags)+>                                              formats (map (No 0) dirs) `handle` abort+>                                              formatStr (addEndEOF str)+>                                              stopexternals)+>   where   addEndEOF           =  (++"%EOF\n") . unlines . lines++> input                         :: [String] -> IO (String, FilePath)+> input []                      =  do s <- getContents; return (s, "<stdin>")+> input ["-"]                   =  do s <- getContents; return (s, "<stdin>")+> input (filePath : _)          =  do chaseFile [] filePath++Converting command line options into directives.++> uheader                       :: String+> uheader                       =  "lhs2TeX [ options ] files\n\nAvailable options:\n"++ks, 20.07.2003: The short option for @--align@ has been changed into @-A@. Otherwise+@-align@ would not trigger compatibility mode, but be interpreted as a valid option+usage.++ks, 24.03.2004: The long option @--verbose@ has been removed for now, +because with some versions of GHC it triggers ambiguity errors with+@--verb@.++> options                       :: [OptDescr (State -> IO State,[Class] -> [Class],[Style])]+> options                       =+>   [ Option ['h','?'] ["help"](NoArg (return, id, [Help]))                                 "get this help"+>   , Option ['v'] [] {- ["verbose"] -}+>                              (NoArg (\s -> return $ s { verbose = True }, id, []))        "be verbose"+>   , Option ['V'] ["version"] (NoArg (return, id, [Version]))                              "show version"+>   , Option []    ["tt"]      (NoArg (return, id, [Typewriter]))                           "typewriter style"+>   , Option []    ["math"]    (NoArg (return, id, [Math]))                                 "math style"+>   , Option []    ["poly"]    (NoArg (return, id, [Poly]))                                 "poly style"+>   , Option []    ["code"]    (NoArg (return, id, [CodeOnly]))                             "code style"+>   , Option []    ["newcode"] (NoArg (return, id, [NewCode]))                              "new code style"+>   , Option []    ["verb"]    (NoArg (return, id, [Verb]))                                 "verbatim"+>   , Option []    ["pre"]     (NoArg (return, id, [Pre]))                                  "act as ghc preprocessor"+>   , Option ['o'] ["output"]  (ReqArg (\f -> (\s -> do h <- openFile f WriteMode+>                                                       return $ s { output = h }, id, [])) "file") "specify output file"+>   , Option []    ["file-directives"]+>                              (NoArg (\s -> return $ s { fldir = True }, id, []))          "generate %file directives"+>   , Option ['A'] ["align"]   (ReqArg (\c -> (return, (Directive Align c:), [])) "col")    "align at <col>"+>   , Option ['i'] ["include"] (ReqArg (\f -> (return, (Directive Include f:), [])) "file") "include <file>"+>   , Option ['l'] ["let"]     (ReqArg (\s -> (return, (Directive Let s:), [])) "equation") "assume <equation>"+>   , Option ['s'] ["set"]     (ReqArg (\s -> (return, (Directive Let (s ++ "=True"):), [])) "flag")  "set <flag>"+>   , Option ['u'] ["unset"]   (ReqArg (\s -> (return, (Directive Let (s ++ "=False"):), [])) "flag") "unset <flag>"+>   , Option ['P'] ["path"]    (ReqArg (\p -> (\s -> return $ s { searchpath = modifySearchPath (searchpath s) p }, id , [])) "path") +>                                                                                       "modify search path"+>   , Option []    ["searchpath"]+>                              (NoArg (return, id, [SearchPath]))                           "show searchpath"+>   , Option []    ["copying"] (NoArg (return, id, [Copying]))                              "display license"+>   , Option []    ["warranty"](NoArg (return, id, [Warranty]))                             "info about warranty"+>   ]+>+> formatStr                     :: String -> Formatter+> formatStr str                 =  formats (texparse 1 str) `handle` abort++Compatibility mode option handling.++> cstyle                        :: [String] -> IO ()+> cstyle args@(('-':a) : x)     =  case encode a of+>   Just sty                    -> cstyle' sty x+>   Nothing                     -> cstyle' Typewriter args+> cstyle args                   =  cstyle' Typewriter args++> cstyle'                       :: Style -> [String] -> IO ()+> cstyle' s args                =  let (dirs,files) = coptions args+>                                  in  lhs2TeX s state0 dirs files++> coptions                      :: [String] -> ([Class], [String])+> coptions                      =  foldr (<|) ([], [])+>   where+>   "-align" <| (ds, s : as)    =  (Directive Align s : ds, as)+>   "-i" <| (ds, s : as)        =  (Directive Include s : ds, as)+>   "-l" <| (ds, s : as)        =  (Directive Let s : ds, as)+>   ('-' : 'i' : s) <| (ds, as) =  (Directive Include s : ds, as)+>   ('-' : 'l' : s) <| (ds, as) =  (Directive Let s : ds, as)+>   s <| (ds, as)               =  (ds, s : as)+++We abort immediately if an error has occured.++> abort                         :: Exc -> Formatter+> abort (msg, context)          =  do st <- fetch+>                                     fromIO (hPutStrLn stderr (text st))+>                                     fromIO (exitWith (ExitFailure 1))+>     where text st             =  "*** Error in " ++ at (file st) (lineno st) ++ ": \n"+>                               ++ unlines [ "included from " ++ at f l | (f, l) <- (files st) ]+>                               ++ msg ++ "\n"+>                               ++ unlines (take 4 (lines context))+>           at f n              =  "file " ++ f ++ " line " ++ show n++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Formatting}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> formats                       :: [Numbered Class] -> Formatter+> formats []                    =  return ()+> formats (No n  (Directive d s) : ts)+>     | conditional d           =  do update (\st -> st{lineno = n})+>                                     st <- fetch+>                                     directive d s (file st,n) +>                                                   (conds st) (toggles st) ts+> formats (No n t : ts)         =  do update (\st -> st{lineno = n})+>                                     format t+>                                     formats ts++> format                        :: Class -> Formatter+> -- |format (Many ('%' : '%' : _))     =  return ()|   -- @%%@-Kommentare werden entfernt+> format (Many s)               =  out (Text s)+> format (Inline s)             =  inline s+> format (Command Hs s)         =  inline s+> format (Command (Vrb b) s)    =  out (Verbatim.inline b s)+> format (Command Eval s)       =  do st <- fetch+>                                     when (not (style st `elem` [CodeOnly,NewCode])) $+>                                       do result <- external (map unNL s)+>                                          inline result+> format (Command Perform s)    =  do st <- fetch+>                                     when (not (style st `elem` [CodeOnly,NewCode])) $+>                                       do result <- external s+>                                          out (Text (trim result))+>     where++Remove trailing blank line.++>     trim                      =  reverse .> skip .> reverse+>+>     skip s | all isSpace t    =  u+>            | otherwise        =  s+>            where (t, u)       =  breakAfter (== '\n') s++> format (Environment Haskell s)=  display s+> format (Environment Code s)   =  display s+> format (Environment Spec s)   =  do st <- fetch+>                                     when (not (style st `elem` [CodeOnly,NewCode])) $+>                                       display s+> format (Environment Evaluate s )+>                               =  do st <- fetch+>                                     result <- external (map unNL s)+>                                     --fromIO (hPutStrLn stderr result)        -- TEST+>                                     display result+> format (Environment Hide s)   =  return ()+> format (Environment Ignore s) =  return ()+> format (Environment (Verbatim b) s)+>                               =  out (Verbatim.display 120 b s)+> format (Directive Format s)   =  do st <- fetch+>                                     b@(n,e) <- fromEither (parseFormat s)+>                                     store (st{fmts = FM.add b (fmts st)})+> format (Directive Subst s)    =  do st <- fetch+>                                     b <- fromEither (parseSubst s)+>                                     store (st{subst = FM.add b (subst st)})+> format (Directive Include arg)=  do st <- fetch+>                                     let d  = path st+>                                     let sp = searchpath st+>                                     update (\st@State{file = f', lineno = l'} ->+>                                         st{file = f, files = (f', l') : files st, path = d ++ dir f})+>                                     -- |d <- fromIO getCurrentDirectory|+>                                     -- |fromIO (setCurrentDirectory (dir f))|+>                                     (str,f) <- fromIO (chaseFile sp (d ++ f))+>                                     update (\st -> st { file = f })+>                                     fromIO (when (verbose st) (hPutStr stderr $ "(" ++ f))+>                                     formatStr (addEndNL str)+>                                     -- |fromIO (setCurrentDirectory d)|+>                                     update (\st'@State{files = (f, l) : fs} ->+>                                         st'{file = f, lineno = l, files = fs, path = d})+>                                     fromIO (when (verbose st) (hPutStrLn stderr $ ")"))+>     where f                   =  withoutSpaces arg+>           addEndNL            =  (++"\n") . unlines . lines++ks, 25.01.2003: If added the above function at the suggestion of NAD, but+I am not completely sure if this is the right thing to do. Maybe we should+strip blank lines from the end of a file as well, maybe we should do nothing+at all. Hard to say what people think is intuitive. Anyway, the reason why+I added it is this: if an %include directive is immediately followed+by another line and the included file does not end in a blank line, then+there will not be a single space between the last character of the included+file and the first character of the following line. It would be possible+to split a TeX control sequence over two different files that way. Seems+strange. So we add a newline, or even two if none has been there before, +to make sure that exactly one linebreak ends up in the output, but not+more, as a double newline is interpreted as a \par by TeX, and that might +also not be desired.++> format (Directive Begin _)    =  update (\st -> st{stack = fmts st : stack st})+> format (Directive End _)      =  do st <- fetch+>                                     when (null (stack st)) $+>                                       do fromIO (hPutStrLn stderr $ "unbalanced %} in line " +>                                                                       ++ show (lineno st))+>                                          update (\st -> st{stack = [fmts st]})+>                                     update (\st@State{stack = d:ds} -> st{fmts = d, stack = ds})++ks, 11.09.03: added exception handling for unbalanced grouping++\Todo{|toggles| should be saved, as well.}++> format (Directive Let s)      =  do st <- fetch+>                                     t <- fromEither (define (toggles st) s)+>                                     store st{toggles = FM.add t (toggles st)}+> format (Directive Align s)+>     | all isSpace s           =  update (\st -> st{align = Nothing, stacks  = ([], [])})+>     | otherwise               =  update (\st -> st{align = Just (read s), stacks  = ([], [])})++\NB @%align@ also resets the left identation stacks.++Also, the @poly@ directives @%separation@ and @%latency@ reset +the corresponding indentation stack |pstack|.++> format (Directive Separation s )+>                               =  update (\st -> st{separation = read s, pstack = []})+> format (Directive Latency s)  =  update (\st -> st{latency = read s, pstack = []})  ++> format (Directive File s)     =  update (\st -> st{file = withoutSpaces s})+> format (Directive Options s)  =  update (\st -> st{opts = trim s})+>     where trim                =  dropWhile isSpace .> reverse .> dropWhile isSpace .> reverse++> format (Error exc)            =  raise exc++Printing documents.+%{+%format d1+%format d2++> eject                         :: Doc -> Formatter+> eject Empty                   =  return ()+> eject (Text s)                =  do  st <- fetch+>                                      let (ls,enl) = checkNLs 0 s+>                                      when (fldir st && not (null s) && atnewline st && (ofile st /= file st || olineno st /= lineno st)) $+>                                        do  fromIO (hPutStr (output st) ("%file " ++ show (lineno st) ++ " " ++ (show $ file st) ++ "\n"))+>                                            store (st { ofile = file st, olineno = lineno st })+>                                            +>                                      fromIO (hPutStr (output st) s)+>                                      update (\st -> st { olineno = olineno st + ls, atnewline = enl (atnewline st)})+>     where+>     checkNLs n ('\n':[])      =  (n+1,const True)+>     checkNLs n (_:[])         =  (n,const False)+>     checkNLs n []             =  (n,id)+>     checkNLs n ('\n':xs)      =  checkNLs (n+1) xs+>     checkNLs n (_:xs)         =  checkNLs n xs+> eject (d1 :^: d2)             =  eject d1 >> eject d2+> eject (Embedded s)            =  formatStr s+> eject (Sub s ds)              =  do st <- fetch; substitute (subst st)+>     where+>     substitute d              =  case FM.lookup s d of+>         Nothing               -> raise (undef s, "")+>         Just sub              -> eject (sub ds)+>+> undef                         :: String -> String+> undef s                       =  "`" ++ s ++ "' is not defined;\n\+>                                  \perhaps you forgot to include \"lhs2TeX.fmt\"?"++%}++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Style dependent formatting}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> out                           :: Doc -> Formatter+> out d                         =  do st <- fetch; eject (select (style st))+>     where select CodeOnly     =  Empty+>           select NewCode      =  Empty+>           select _            =  d++> inline, display               :: String -> Formatter+> inline s                      =  do st <- fetch+>                                     d <- fromEither (select (style st) st)+>                                     eject d+>   where select Verb st        =  Right (Verbatim.inline False s)+>         select Typewriter st  =  Typewriter.inline (fmts st) s+>         select Math st        =  Math.inline (fmts st) (isTrue (toggles st) auto) s+>         select Poly st        =  Poly.inline (fmts st) (isTrue (toggles st) auto) s+>         select CodeOnly st    =  return Empty+>         select NewCode st     =  return Empty   -- generate PRAGMA or something?++> display s                     =  do st <- fetch+>                                     (d, st') <- fromEither (select (style st) st)+>                                     store st'+>                                     eject d+>   where select Verb st        =  return (Verbatim.display 120 False s, st)+>         select Typewriter st  =  do d <- Typewriter.display (fmts st) s; return (d, st)+>         select Math st        =  do (d, sts) <- Math.display (fmts st) (isTrue (toggles st) auto) (stacks st) (align st) s+>                                     return (d, st{stacks = sts})+>         select Poly st        =  do (d, pstack') <- Poly.display (fmts st) (isTrue (toggles st) auto) (separation st) (latency st) (pstack st) s+>                                     return (d, st{pstack = pstack'})+>         select NewCode st     =  do d <- NewCode.display (fmts st) s+>                                     let p = sub'pragma $ Text ("LINE " ++ show (lineno st + 1) ++ " " ++ show (filename $ file st))+>                                     return (p <> sub'nl <> d, st)+>         select CodeOnly st    =  return (Text (trim s), st)++> auto                          =  "autoSpacing"+> isTrue togs s                 =  bool (value togs s)++Delete leading and trailing blank line (only the first!).++> trim                          :: String -> String+> trim                          =  skip .> reverse .> skip .> reverse+>     where+>     skip                      :: String -> String+>     skip ""                   =  ""+>     skip s | all isSpace t    =  u+>            | otherwise        =  s+>            where (t, u)       =  breakAfter (== '\n') s++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Conditional directives}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++A stack of Boolean values holds the conditions of+@%if@-directives.  Perhaps surpsingly, each @%if@ gives rise+to \emph{two} entries; if @%elif@ is not used the second entry is+always |True|, otherwise it holds the negation of all previous+conditions of the current @%if@-chain.++ks, 16.08.2004: At the end of the input, we might want to check for unbalanced if's or+groups.++> directive                     :: Directive -> String +>                               -> (FilePath,LineNo) -> [CondInfo] -> Toggles+>                               -> [Numbered Class] -> Formatter+> directive d s (f,l) stack togs ts+>                               =  dir d s stack+>   where+>   dir If s bs                 =  do b <- fromEither (eval togs s)+>                                     skipOrFormat ((f, l, bool b, True) : bs) ts+>   dir Elif s ((f,l,b2,b1):bs) =  do b <- fromEither (eval togs s)+>                                     skipOrFormat ((f, l, bool b, not b2 && b1) : bs) ts+>   dir Else _ ((f,l,b2,b1):bs) =  skipOrFormat ((f, l, not b2 && b1, True) : bs) ts+>   dir Endif _ ((f,l,b2,b1):bs)=  skipOrFormat bs ts+>   dir EOF _ []                =  return ()  -- nothing left to do+>   dir EOF s bs                =  raise (init $ unlines (map unBalancedIf bs), s)+>   dir d s _                   =  raise ("spurious %" ++ decode d, s)++> skipOrFormat                  :: [CondInfo] -> [Numbered Class] -> Formatter+> skipOrFormat stack ts         =  do  update (\st -> st{conds = stack})+>                                      if andS stack  then formats ts+>                                                     else skip ts++> andS                          :: [CondInfo] -> Bool+> andS                          =  and . map (\(_,_,x,y) -> x && y)++> unBalancedIf                  :: CondInfo -> String+> unBalancedIf (f,l,_,_)        =  "%if at " ++ f ++ " line " ++ show l ++ " not closed"++> skip                          :: [Numbered Class] -> Formatter+> skip []                       =  return ()+> skip ts@(No n  (Directive d s) : _)+>     | conditional d           =  formats ts+> skip (t : ts)                 =  skip ts++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Active commands}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++ks, 23.10.2003: extended to work with @ghci@, too.+ks, 03.01.2004: fixed to work with @ghci-6.2@, hopefully without breaking+@hugs@ or old @ghci@ compatibility.++New, 26.01.2006: we're now starting an external process @ghci@ or @hugs@+using the System.Process library. The process is then reused for subsequent+computations, which should dramatically improve compilation time for+documents that make extensive use of @\eval@ and @\perform@.++> type Externals    =  FM.FiniteMap Char ProcessInfo+> type ProcessInfo  =  (Handle, Handle, Handle, ProcessHandle)++The function |external| can be used to call the process. It is discouraged+to call any programs except @ghci@ or @hugs@, because we make a number of+assumptions about the program being called. Input is the expression to evaluate.+Output is the result in string form.++> external                      :: String -> XIO Exc State String+> external expr                 =  do st <- fetch+>                                     let os  =  opts st+>                                         f   =  file st+>                                         ex  =  externals st+>                                         ghcimode       =  "ghci" `isPrefix` os+>                                         cmd+>                                           | ghcimode   =  os ++ " -v0 -ignore-dot-ghci " ++ f+>                                           | otherwise  =  (if null os then "hugs " else os ++ " ") ++ f+>                                         script         =  "putStrLn " ++ show magic ++ "\n"+>                                                             ++ expr ++ "\n"+>                                                             ++ "putStrLn " ++ show magic ++ "\n"+>                                     pi <- case FM.lookup f ex of+>                                             Just pi  ->  return pi+>                                             Nothing  ->  -- start new external process+>                                                          fromIO $ do+>                                                            when (verbose st) $+>                                                              hPutStrLn stderr $ "Starting external process: " ++ cmd+>                                                            runInteractiveCommand cmd+>                                     store (st {externals = FM.add (f,pi) ex})+>                                     let (pin,pout,_,_) = pi+>                                     fromIO $ do+>                                       hPutStr pin script+>                                       hFlush pin+>                                       extract' pout++This function can be used to stop all external processes by sending the+@:q@ command to them.++> stopexternals                 :: Formatter+> stopexternals                 =  do st <- fetch+>                                     let ex   =  externals st+>                                         pis  =  map (ex FM.!) (FM.keys ex)+>                                     when (not . null $ pis) $ fromIO $ do+>                                       when (verbose st) $+>                                         hPutStrLn stderr $ "Stopping external processes."+>                                       mapM_ (\(pin,_,_,pid) -> do  hPutStrLn pin ":q"+>                                                                    hFlush pin+>                                                                    waitForProcess pid) pis++To extract the answer from @ghci@'s or @hugs@' output +we use a simple technique which should work in+most cases: we print the string |magic| before and after+the expression we are interested in. We assume that everything+that appears before the first occurrence of |magic| on the same+line is the prompt, and everything between the first |magic|+and the second |magic| plus prompt is the result we look for.++> magic                         :: String+> magic                         =  "!@#$^&*"+>+> extract'                      :: Handle -> IO String+> extract' h                    =  fmap (extract . unlines) (readMagic 2)+>     where readMagic           :: Int -> IO [String]+>           readMagic 0         =  return []+>           readMagic n         =  do  l <- hGetLine h+>                                      let n'  |  (null . snd . breaks (isPrefix magic)) l  =  n+>                                              |  otherwise                                 =  n - 1+>                                      fmap (l:) (readMagic n')++> extract                       :: String -> String+> extract s                     =  v+>     where (t, u)              =  breaks (isPrefix magic) s+>           -- t contains everything up to magic, u starts with magic+>           -- |u'                      =  tail (dropWhile (/='\n') u)|+>           pre                 =  reverse . takeWhile (/='\n') . reverse $ t+>           prelength           =  if null pre then 0 else length pre + 1+>           -- pre contains the prefix of magic on the same line+>           u'                  =  drop (length magic + prelength) u+>           -- we drop the magic string, plus the newline, plus the prefix+>           (v, _)              =  breaks (isPrefix (pre ++ magic)) u'+>           -- we look for the next occurrence of prefix plus magic++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Reading files}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> dir, nondir                   :: FilePath -> FilePath+> dir filePath+>     | null d                  =  ""+>     | otherwise               =  reverse d+>     where d                   =  dropWhile (/= '/') (reverse filePath)+>+> nondir                        =  reverse . takeWhile (/= '/') . reverse++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{GPL-related program information}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> programInfo                   :: String+> programInfo                   =+>     "lhs2TeX " ++ version ++ ", Copyright (C) 1997-2006 Ralf Hinze, Andres Loeh\n\n\+>     \lhs2TeX comes with ABSOLUTELY NO WARRANTY;\n\+>     \for details type `lhs2TeX --warranty'.\n\+>     \This is free software, and you are welcome to redistribute it\n\+>     \under certain conditions; type `lhs2TeX --copying' for details."++> copying                       :: String+> copying                       =+>     "\t\t    GNU GENERAL PUBLIC LICENSE\n\+>     \\t\t       Version 2, June 1991\n\+>     \\n\+>     \ Copyright (C) 1989, 1991 Free Software Foundation, Inc.\n\+>     \                          59 Temple Place - Suite 330\n\+>     \                          Boston, MA 02111-1307, USA.\n\+>     \ Everyone is permitted to copy and distribute verbatim copies\n\+>     \ of this license document, but changing it is not allowed.\n\+>     \\n\+>     \\t\t\t    Preamble\n\+>     \\n\+>     \  The licenses for most software are designed to take away your\n\+>     \freedom to share and change it.  By contrast, the GNU General Public\n\+>     \License is intended to guarantee your freedom to share and change free\n\+>     \software--to make sure the software is free for all its users.  This\n\+>     \General Public License applies to most of the Free Software\n\+>     \Foundation's software and to any other program whose authors commit to\n\+>     \using it.  (Some other Free Software Foundation software is covered by\n\+>     \the GNU Library General Public License instead.)  You can apply it to\n\+>     \your programs, too.\n\+>     \\n\+>     \  When we speak of free software, we are referring to freedom, not\n\+>     \price.  Our General Public Licenses are designed to make sure that you\n\+>     \have the freedom to distribute copies of free software (and charge for\n\+>     \this service if you wish), that you receive source code or can get it\n\+>     \if you want it, that you can change the software or use pieces of it\n\+>     \in new free programs; and that you know you can do these things.\n\+>     \\n\+>     \  To protect your rights, we need to make restrictions that forbid\n\+>     \anyone to deny you these rights or to ask you to surrender the rights.\n\+>     \These restrictions translate to certain responsibilities for you if you\n\+>     \distribute copies of the software, or if you modify it.\n\+>     \\n\+>     \  For example, if you distribute copies of such a program, whether\n\+>     \gratis or for a fee, you must give the recipients all the rights that\n\+>     \you have.  You must make sure that they, too, receive or can get the\n\+>     \source code.  And you must show them these terms so they know their\n\+>     \rights.\n\+>     \\n\+>     \  We protect your rights with two steps: (1) copyright the software, and\n\+>     \(2) offer you this license which gives you legal permission to copy,\n\+>     \distribute and/or modify the software.\n\+>     \\n\+>     \  Also, for each author's protection and ours, we want to make certain\n\+>     \that everyone understands that there is no warranty for this free\n\+>     \software.  If the software is modified by someone else and passed on, we\n\+>     \want its recipients to know that what they have is not the original, so\n\+>     \that any problems introduced by others will not reflect on the original\n\+>     \authors' reputations.\n\+>     \\n\+>     \  Finally, any free program is threatened constantly by software\n\+>     \patents.  We wish to avoid the danger that redistributors of a free\n\+>     \program will individually obtain patent licenses, in effect making the\n\+>     \program proprietary.  To prevent this, we have made it clear that any\n\+>     \patent must be licensed for everyone's free use or not licensed at all.\n\+>     \\n\+>     \  The precise terms and conditions for copying, distribution and\n\+>     \modification follow.\n\+>     \\f\n\+>     \\t\t    GNU GENERAL PUBLIC LICENSE\n\+>     \   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\+>     \\n\+>     \  0. This License applies to any program or other work which contains\n\+>     \a notice placed by the copyright holder saying it may be distributed\n\+>     \under the terms of this General Public License.  The \"Program\", below,\n\+>     \refers to any such program or work, and a \"work based on the Program\"\n\+>     \means either the Program or any derivative work under copyright law:\n\+>     \that is to say, a work containing the Program or a portion of it,\n\+>     \either verbatim or with modifications and/or translated into another\n\+>     \language.  (Hereinafter, translation is included without limitation in\n\+>     \the term \"modification\".)  Each licensee is addressed as \"you\".\n\+>     \\n\+>     \Activities other than copying, distribution and modification are not\n\+>     \covered by this License; they are outside its scope.  The act of\n\+>     \running the Program is not restricted, and the output from the Program\n\+>     \is covered only if its contents constitute a work based on the\n\+>     \Program (independent of having been made by running the Program).\n\+>     \Whether that is true depends on what the Program does.\n\+>     \\n\+>     \  1. You may copy and distribute verbatim copies of the Program's\n\+>     \source code as you receive it, in any medium, provided that you\n\+>     \conspicuously and appropriately publish on each copy an appropriate\n\+>     \copyright notice and disclaimer of warranty; keep intact all the\n\+>     \notices that refer to this License and to the absence of any warranty;\n\+>     \and give any other recipients of the Program a copy of this License\n\+>     \along with the Program.\n\+>     \\n\+>     \You may charge a fee for the physical act of transferring a copy, and\n\+>     \you may at your option offer warranty protection in exchange for a fee.\n\+>     \\n\+>     \  2. You may modify your copy or copies of the Program or any portion\n\+>     \of it, thus forming a work based on the Program, and copy and\n\+>     \distribute such modifications or work under the terms of Section 1\n\+>     \above, provided that you also meet all of these conditions:\n\+>     \\n\+>     \    a) You must cause the modified files to carry prominent notices\n\+>     \    stating that you changed the files and the date of any change.\n\+>     \\n\+>     \    b) You must cause any work that you distribute or publish, that in\n\+>     \    whole or in part contains or is derived from the Program or any\n\+>     \    part thereof, to be licensed as a whole at no charge to all third\n\+>     \    parties under the terms of this License.\n\+>     \\n\+>     \    c) If the modified program normally reads commands interactively\n\+>     \    when run, you must cause it, when started running for such\n\+>     \    interactive use in the most ordinary way, to print or display an\n\+>     \    announcement including an appropriate copyright notice and a\n\+>     \    notice that there is no warranty (or else, saying that you provide\n\+>     \    a warranty) and that users may redistribute the program under\n\+>     \    these conditions, and telling the user how to view a copy of this\n\+>     \    License.  (Exception: if the Program itself is interactive but\n\+>     \    does not normally print such an announcement, your work based on\n\+>     \    the Program is not required to print an announcement.)\n\+>     \\f\n\+>     \These requirements apply to the modified work as a whole.  If\n\+>     \identifiable sections of that work are not derived from the Program,\n\+>     \and can be reasonably considered independent and separate works in\n\+>     \themselves, then this License, and its terms, do not apply to those\n\+>     \sections when you distribute them as separate works.  But when you\n\+>     \distribute the same sections as part of a whole which is a work based\n\+>     \on the Program, the distribution of the whole must be on the terms of\n\+>     \this License, whose permissions for other licensees extend to the\n\+>     \entire whole, and thus to each and every part regardless of who wrote it.\n\+>     \\n\+>     \Thus, it is not the intent of this section to claim rights or contest\n\+>     \your rights to work written entirely by you; rather, the intent is to\n\+>     \exercise the right to control the distribution of derivative or\n\+>     \collective works based on the Program.\n\+>     \\n\+>     \In addition, mere aggregation of another work not based on the Program\n\+>     \with the Program (or with a work based on the Program) on a volume of\n\+>     \a storage or distribution medium does not bring the other work under\n\+>     \the scope of this License.\n\+>     \\n\+>     \  3. You may copy and distribute the Program (or a work based on it,\n\+>     \under Section 2) in object code or executable form under the terms of\n\+>     \Sections 1 and 2 above provided that you also do one of the following:\n\+>     \\n\+>     \    a) Accompany it with the complete corresponding machine-readable\n\+>     \    source code, which must be distributed under the terms of Sections\n\+>     \    1 and 2 above on a medium customarily used for software interchange; or,\n\+>     \\n\+>     \    b) Accompany it with a written offer, valid for at least three\n\+>     \    years, to give any third party, for a charge no more than your\n\+>     \    cost of physically performing source distribution, a complete\n\+>     \    machine-readable copy of the corresponding source code, to be\n\+>     \    distributed under the terms of Sections 1 and 2 above on a medium\n\+>     \    customarily used for software interchange; or,\n\+>     \\n\+>     \    c) Accompany it with the information you received as to the offer\n\+>     \    to distribute corresponding source code.  (This alternative is\n\+>     \    allowed only for noncommercial distribution and only if you\n\+>     \    received the program in object code or executable form with such\n\+>     \    an offer, in accord with Subsection b above.)\n\+>     \\n\+>     \The source code for a work means the preferred form of the work for\n\+>     \making modifications to it.  For an executable work, complete source\n\+>     \code means all the source code for all modules it contains, plus any\n\+>     \associated interface definition files, plus the scripts used to\n\+>     \control compilation and installation of the executable.  However, as a\n\+>     \special exception, the source code distributed need not include\n\+>     \anything that is normally distributed (in either source or binary\n\+>     \form) with the major components (compiler, kernel, and so on) of the\n\+>     \operating system on which the executable runs, unless that component\n\+>     \itself accompanies the executable.\n\+>     \\n\+>     \If distribution of executable or object code is made by offering\n\+>     \access to copy from a designated place, then offering equivalent\n\+>     \access to copy the source code from the same place counts as\n\+>     \distribution of the source code, even though third parties are not\n\+>     \compelled to copy the source along with the object code.\n\+>     \\f\n\+>     \  4. You may not copy, modify, sublicense, or distribute the Program\n\+>     \except as expressly provided under this License.  Any attempt\n\+>     \otherwise to copy, modify, sublicense or distribute the Program is\n\+>     \void, and will automatically terminate your rights under this License.\n\+>     \However, parties who have received copies, or rights, from you under\n\+>     \this License will not have their licenses terminated so long as such\n\+>     \parties remain in full compliance.\n\+>     \\n\+>     \  5. You are not required to accept this License, since you have not\n\+>     \signed it.  However, nothing else grants you permission to modify or\n\+>     \distribute the Program or its derivative works.  These actions are\n\+>     \prohibited by law if you do not accept this License.  Therefore, by\n\+>     \modifying or distributing the Program (or any work based on the\n\+>     \Program), you indicate your acceptance of this License to do so, and\n\+>     \all its terms and conditions for copying, distributing or modifying\n\+>     \the Program or works based on it.\n\+>     \\n\+>     \  6. Each time you redistribute the Program (or any work based on the\n\+>     \Program), the recipient automatically receives a license from the\n\+>     \original licensor to copy, distribute or modify the Program subject to\n\+>     \these terms and conditions.  You may not impose any further\n\+>     \restrictions on the recipients' exercise of the rights granted herein.\n\+>     \You are not responsible for enforcing compliance by third parties to\n\+>     \this License.\n\+>     \\n\+>     \  7. If, as a consequence of a court judgment or allegation of patent\n\+>     \infringement or for any other reason (not limited to patent issues),\n\+>     \conditions are imposed on you (whether by court order, agreement or\n\+>     \otherwise) that contradict the conditions of this License, they do not\n\+>     \excuse you from the conditions of this License.  If you cannot\n\+>     \distribute so as to satisfy simultaneously your obligations under this\n\+>     \License and any other pertinent obligations, then as a consequence you\n\+>     \may not distribute the Program at all.  For example, if a patent\n\+>     \license would not permit royalty-free redistribution of the Program by\n\+>     \all those who receive copies directly or indirectly through you, then\n\+>     \the only way you could satisfy both it and this License would be to\n\+>     \refrain entirely from distribution of the Program.\n\+>     \\n\+>     \If any portion of this section is held invalid or unenforceable under\n\+>     \any particular circumstance, the balance of the section is intended to\n\+>     \apply and the section as a whole is intended to apply in other\n\+>     \circumstances.\n\+>     \\n\+>     \It is not the purpose of this section to induce you to infringe any\n\+>     \patents or other property right claims or to contest validity of any\n\+>     \such claims; this section has the sole purpose of protecting the\n\+>     \integrity of the free software distribution system, which is\n\+>     \implemented by public license practices.  Many people have made\n\+>     \generous contributions to the wide range of software distributed\n\+>     \through that system in reliance on consistent application of that\n\+>     \system; it is up to the author/donor to decide if he or she is willing\n\+>     \to distribute software through any other system and a licensee cannot\n\+>     \impose that choice.\n\+>     \\n\+>     \This section is intended to make thoroughly clear what is believed to\n\+>     \be a consequence of the rest of this License.\n\+>     \\f\n\+>     \  8. If the distribution and/or use of the Program is restricted in\n\+>     \certain countries either by patents or by copyrighted interfaces, the\n\+>     \original copyright holder who places the Program under this License\n\+>     \may add an explicit geographical distribution limitation excluding\n\+>     \those countries, so that distribution is permitted only in or among\n\+>     \countries not thus excluded.  In such case, this License incorporates\n\+>     \the limitation as if written in the body of this License.\n\+>     \\n\+>     \  9. The Free Software Foundation may publish revised and/or new versions\n\+>     \of the General Public License from time to time.  Such new versions will\n\+>     \be similar in spirit to the present version, but may differ in detail to\n\+>     \address new problems or concerns.\n\+>     \\n\+>     \Each version is given a distinguishing version number.  If the Program\n\+>     \specifies a version number of this License which applies to it and \"any\n\+>     \later version\", you have the option of following the terms and conditions\n\+>     \either of that version or of any later version published by the Free\n\+>     \Software Foundation.  If the Program does not specify a version number of\n\+>     \this License, you may choose any version ever published by the Free Software\n\+>     \Foundation.\n\+>     \\n\+>     \  10. If you wish to incorporate parts of the Program into other free\n\+>     \programs whose distribution conditions are different, write to the author\n\+>     \to ask for permission.  For software which is copyrighted by the Free\n\+>     \Software Foundation, write to the Free Software Foundation; we sometimes\n\+>     \make exceptions for this.  Our decision will be guided by the two goals\n\+>     \of preserving the free status of all derivatives of our free software and\n\+>     \of promoting the sharing and reuse of software generally.\n\+>     \\n"+>     ++ warranty +++>     "\n\n\+>     \\t\t     END OF TERMS AND CONDITIONS\n\+>     \\f\n\+>     \\t    How to Apply These Terms to Your New Programs\n\+>     \\n\+>     \  If you develop a new program, and you want it to be of the greatest\n\+>     \possible use to the public, the best way to achieve this is to make it\n\+>     \free software which everyone can redistribute and change under these terms.\n\+>     \\n\+>     \  To do so, attach the following notices to the program.  It is safest\n\+>     \to attach them to the start of each source file to most effectively\n\+>     \convey the exclusion of warranty; and each file should have at least\n\+>     \the \"copyright\" line and a pointer to where the full notice is found.\n\+>     \\n\+>     \    <one line to give the program's name and a brief idea of what it does.>\n\+>     \    Copyright (C) 19yy  <name of author>\n\+>     \\n\+>     \    This program is free software; you can redistribute it and/or modify\n\+>     \    it under the terms of the GNU General Public License as published by\n\+>     \    the Free Software Foundation; either version 2 of the License, or\n\+>     \    (at your option) any later version.\n\+>     \\n\+>     \    This program is distributed in the hope that it will be useful,\n\+>     \    but WITHOUT ANY WARRANTY; without even the implied warranty of\n\+>     \    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n\+>     \    GNU General Public License for more details.\n\+>     \\n\+>     \    You should have received a copy of the GNU General Public License\n\+>     \    along with this program; see the file COPYING.  If not, write to\n\+>     \    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,\n\+>     \    Boston, MA 02111-1307, USA.\n\+>     \\n\+>     \Also add information on how to contact you by electronic and paper mail.\n\+>     \\n\+>     \If the program is interactive, make it output a short notice like this\n\+>     \when it starts in an interactive mode:\n\+>     \\n\+>     \    Gnomovision version 69, Copyright (C) 19yy name of author\n\+>     \    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n\+>     \    This is free software, and you are welcome to redistribute it\n\+>     \    under certain conditions; type `show c' for details.\n\+>     \\n\+>     \The hypothetical commands `show w' and `show c' should show the appropriate\n\+>     \parts of the General Public License.  Of course, the commands you use may\n\+>     \be called something other than `show w' and `show c'; they could even be\n\+>     \mouse-clicks or menu items--whatever suits your program.\n\+>     \\n\+>     \You should also get your employer (if you work as a programmer) or your\n\+>     \school, if any, to sign a \"copyright disclaimer\" for the program, if\n\+>     \necessary.  Here is a sample; alter the names:\n\+>     \\n\+>     \  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n\+>     \  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\+>     \\n\+>     \  <signature of Ty Coon>, 1 April 1989\n\+>     \  Ty Coon, President of Vice\n\+>     \\n\+>     \This General Public License does not permit incorporating your program into\n\+>     \proprietary programs.  If your program is a subroutine library, you may\n\+>     \consider it more useful to permit linking proprietary applications with the\n\+>     \library.  If this is what you want to do, use the GNU Library General\n\+>     \Public License instead of this License."++> warranty                      :: String+> warranty                      =+>     "\t\t\t    NO WARRANTY\n\+>     \\n\+>     \  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\n\+>     \FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\n\+>     \OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\n\+>     \PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\n\+>     \OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n\+>     \MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\n\+>     \TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\n\+>     \PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\n\+>     \REPAIR OR CORRECTION.\n\+>     \\n\+>     \  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\n\+>     \WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\n\+>     \REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\n\+>     \INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\n\+>     \OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\n\+>     \TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\n\+>     \YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\n\+>     \PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\n\+>     \POSSIBILITY OF SUCH DAMAGES."
+ Makefile view
@@ -0,0 +1,244 @@++include config.mk++main            := Main.lhs+psources        := $(main) TeXCommands.lhs TeXParser.lhs \+		   Typewriter.lhs Math.lhs MathPoly.lhs \+                   MathCommon.lhs NewCode.lhs \+		   Directives.lhs HsLexer.lhs FileNameUtils.lhs \+		   Parser.lhs FiniteMap.lhs Auxiliaries.lhs \+		   StateT.lhs Document.lhs Verbatim.lhs Value.lhs+sources         := $(psources) Version.lhs+snipssrc        := sorts.snip id.snip cata.snip spec.snip+snips	        := sorts.tt sorts.math id.math cata.math spec.math+objects         := $(sources:.lhs=.o)+sections       	:= $(sources:.lhs=.tex)++MKINSTDIR       := ./mkinstalldirs++###+### lhs dependencies (from %include lines)+###++ifdef SORT+ifdef UNIQ++MKLHSDEPEND = $(GREP) "^%include " $< \+               | $(SED) -e 's,^%include ,$*.tex : ,' \+               | $(SORT) | $(UNIQ) > $*.ld++MKFMTDEPEND = $(GREP) "^%include " $< \+               | $(SED) -e 's,^%include ,$*.fmt : ,' \+               | $(SORT) | $(UNIQ) > $*.ld++endif+endif++###+### dependency postprocessing+###++DEPPOSTPROC = $(SED) -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \+	         -e '/^$$/ d' -e 's/$$/ :/'++###+### default targets+###++.PHONY : default xdvi gv print install backup clean all depend bin doc srcdist++all : default++default : bin doc+bin : lhs2TeX lhs2TeX.fmt lhs2TeX.sty++-include $(sources:%.lhs=%.d)++# I don't understand this ... (ks)+#+# %.hi : %.o+# 	@if [ ! -f $@ ] ; then \+#	echo $(RM) $< ; \+#	$(RM) $< ; \+#	set +e ; \+#	echo $(MAKE) $(notdir $<) ; \+#	$(MAKE) $(notdir $<) ; \+#	if [ $$? -ne 0 ] ; then \+#	exit 1; \+#	fi ; \+#	fi++ifdef MKLHSDEPEND++%.ld : %.lhs+	$(MKLHSDEPEND); \+	$(CP) $*.ld $*.ldd; \+	$(DEPPOSTPROC) < $*.ldd >> $*.ld; \+	$(RM) -f $*.ldd++%.ld : %.fmt+	$(MKFMTDEPEND); \+	$(CP) $*.ld $*.ldd; \+	$(DEPPOSTPROC) < $*.ldd >> $*.ld; \+	$(RM) -f $*.ldd++-include $(sources:%.lhs=%.ld)++endif++%.tex : %.lhs lhs2TeX Lhs2TeX.fmt lhs2TeX.fmt+#	lhs2TeX -verb -iLhs2TeX.fmt $< > $@+	./lhs2TeX --math --align 33 -iLhs2TeX.fmt $< > $@++%.tt : %.snip lhs2TeX lhs2TeX.fmt+	./lhs2TeX --tt -lmeta=True -ilhs2TeX.fmt $< > $@++%.math : %.snip lhs2TeX lhs2TeX.fmt+	./lhs2TeX --math --align 33 -lmeta=True -ilhs2TeX.fmt $< > $@++%.tex : %.lit lhs2TeX+	./lhs2TeX --verb -ilhs2TeX.fmt $< > $@+++lhs2TeX.sty: lhs2TeX.sty.lit lhs2TeX+	./lhs2TeX --code lhs2TeX.sty.lit > lhs2TeX.sty+lhs2TeX.fmt: lhs2TeX.fmt.lit lhs2TeX+	./lhs2TeX --code lhs2TeX.fmt.lit > lhs2TeX.fmt++lhs2TeX : $(sources)+	$(GHC) $(GHCFLAGS) --make -o lhs2TeX $(main)++doc : bin+	cd doc; $(MAKE)+#	cd Guide; $(MAKE) Guide.pdf++INSTALL : lhs2TeX INSTALL0 INSTALL1+	cp INSTALL0 $@+	./lhs2TeX --searchpath >> $@+	cat INSTALL1 >> $@++depend:+	$(GHC) -M -optdep-f -optdeplhs2TeX.d $(GHCFLAGS) $(sources)+	$(RM) -f lhs2TeX.d.bak++lhs2TeX-includes : lhs2TeX.sty $(sections) $(snips) lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex++Lhs2TeX.dvi : lhs2TeX-includes+Lhs2TeX.pdf : lhs2TeX-includes++xdvi : Lhs2TeX.dvi+	$(XDVI) -s 3 Lhs2TeX.dvi &++gv : Lhs2TeX.ps+	$(GV) Lhs2TeX.ps &++print : Lhs2TeX.dvi+	$(DVIPS) -D600 -f Lhs2TeX.dvi | lpr -Pa -Zl++install : bin doc+	$(MKINSTDIR) $(DESTDIR)$(bindir)+	$(INSTALL) -m 755 lhs2TeX $(DESTDIR)$(bindir)+	$(MKINSTDIR) $(DESTDIR)$(stydir)+	$(INSTALL) -m 644 lhs2TeX.sty lhs2TeX.fmt $(DESTDIR)$(stydir)+	$(INSTALL) -m 644 Library/*.fmt $(DESTDIR)$(stydir)+	$(MKINSTDIR) $(DESTDIR)$(docdir)+	$(INSTALL) -m 644 doc/Guide2.pdf $(DESTDIR)$(docdir)+	$(MKINSTDIR) $(DESTDIR)$(mandir)/man1+	$(INSTALL) -m 644 lhs2TeX.1 $(DESTDIR)$(mandir)/man1+ifeq ($(INSTALL_POLYTABLE),yes)+# install polytable package+	$(MKINSTDIR) $(DESTDIR)$(polydir)+	$(INSTALL) -m 644 polytable/*.sty $(DESTDIR)$(polydir)+endif+	# $(MKINSTDIR) $(DESTDIR)$(texdir)+	# $(INSTALL) -m 644 Library/*.sty $(DESTDIR)$(texdir)+ifndef DESTDIR+	$(MKTEXLSR)+else+	echo "Please update the TeX filename database."+endif++srcdist : INSTALL doc+	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi+	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/doc+	$(MKINSTDIR) $(DISTDIR)/polytable+	$(MKINSTDIR) $(DISTDIR)/Testsuite+	$(MKINSTDIR) $(DISTDIR)/Examples+	$(MKINSTDIR) $(DISTDIR)/Library+	$(INSTALL) -m 644 $(psources) Version.lhs.in $(snipssrc) $(DISTDIR)+	$(INSTALL) -m 644 Setup.hs lhs2tex.cabal $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)+	$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)+	$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE RELEASE $(DISTDIR)+	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \+		> $(DISTDIR)/INSTALL+	chmod 644 $(DISTDIR)/INSTALL+	cd doc; $(MAKE) srcdist+	$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable+	$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Makefile $(DISTDIR)/Testsuite+	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples+	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples+	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library+	tar cvjf $(DISTDIR).tar.bz2 $(DISTDIR)+	chmod 644 $(DISTDIR).tar.bz2++ifdef DISTTYPE++bindist: lhs2TeX lhs2TeX.fmt lhs2TeX.sty doc+	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi+	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/doc+	$(MKINSTDIR) $(DISTDIR)/polytable+	$(MKINSTDIR) $(DISTDIR)/Testsuite+	$(MKINSTDIR) $(DISTDIR)/Examples+	$(MKINSTDIR) $(DISTDIR)/Library+	$(INSTALL) -m 755 lhs2TeX $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt lhs2TeX.sty $(DISTDIR)+	$(INSTALL) -m 644 $(psources) Version.lhs.in $(snipssrc) $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)+	$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)+	$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE RELEASE $(DISTDIR)+	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \+		> $(DISTDIR)/INSTALL+	chmod 644 $(DISTDIR)/INSTALL+	cd doc; $(MAKE) srcdist+	$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable+	$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Makefile $(DISTDIR)/Testsuite+	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples+	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples+	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library+	tar cvjf $(DISTDIR)-$(DISTTYPE).tar.bz2 $(DISTDIR)+	chmod 644 $(DISTDIR)-$(DISTTYPE).tar.bz2++else++bindist:+	@echo "You must define DISTTYPE."++endif++backup:+	cd ..; \+	$(RM) -f Literate.tar Literate.tar.gz; \+	tar -cf Literate.tar Literate; \+	gzip Literate.tar; \+	chmod a+r Literate.tar.gz++clean :+#	clean+	$(RM) -f lhs2TeX $(sections) $(snips) $(objects) *.hi *.dvi *.ps+	-$(RM) -f *.d *.dd *.ld *.ldd+	$(RM) -f lhs2TeX.sty lhs2TeX.fmt+	$(RM) -f Lhs2TeX.tex lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex +	cd doc; $(MAKE) clean++# all:+# 	$(MAKE) install+# 	$(MAKE) Lhs2TeX.dvi++include common.mk
+ Math.lhs view
@@ -0,0 +1,236 @@+%-------------------------------=  --------------------------------------------+\subsection{Math formatter}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Math                   (  module Math, substitute, number  )+> where+>+> import Prelude hiding         (  lines )+> import Data.List              (  partition )+> import Numeric                (  showFFloat )+> import Control.Monad          (  MonadPlus(..) )+>+> import Verbatim               (  expand, trim )+> import Typewriter             (  latex )+> import MathCommon+> import Document+> import Directives+> import HsLexer+> import Parser+> import qualified FiniteMap as FM+> import Auxiliaries++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline                        :: Formats -> Bool -> String -> Either Exc Doc+> inline fmts auto              =  fmap unNL+>                               .> tokenize+>                               @> lift (number 1 1)+>                               @> when auto (lift (filter (isNotSpace . token)))+>                               @> lift (partition (\t -> catCode t /= White))+>                               @> exprParse *** return+>                               @> lift (substitute fmts auto) *** return+>                               @> lift (uncurry merge)+>                               @> lift (fmap token)+>                               @> when auto (lift addSpaces)+>                               @> lift (latexs fmts)+>                               @> lift sub'inline++> display                       :: Formats -> Bool -> (Stack, Stack) -> Maybe Int+>                               -> String -> Either Exc (Doc, (Stack,Stack))+> display fmts auto sts col     =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize+>                               @> lift (number 1 1)+>                               @> when auto (lift (filter (isNotSpace . token)))+>                               @> lift (partition (\t -> catCode t /= White))+>                               @> exprParse *** return+>                               @> lift (substitute fmts auto) *** return+>                               @> lift (uncurry merge)+>                               @> lift lines+>                               @> lift (align col)+>                               @> when auto (lift (fmap (fmap addSpaces)))+>                               @> lift (leftIndent fmts auto sts)+>                               @> lift sub'code *** return++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{A very simple Haskell Parser}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++The parser is based on the Smugweb parser.+This variant cannot handle unbalanced parentheses.++> exprParse                     :: (CToken tok, Show tok) => [Pos tok] -> Either Exc [Item (Pos tok)]+> exprParse s                   =  case run chunk s of+>     Nothing                   -> Left ("syntax error", show s) -- HACK: |show s|+>     Just e                    -> Right e+>+> chunk                         :: (CToken tok) => Parser (Pos tok) (Chunk (Pos tok))+> chunk                         =  do a <- many atom+>                                     as <- many (do s <- sep; a <- many atom; return ([Delim s] ++ offside a))+>                                     return (offside a ++ concat as)+>     where offside []          =  []+>           -- old: |opt a =  [Apply a]|+>           offside (a : as)    =  Apply (a : bs) : offside cs+>               where (bs, cs)  =  span (\a' -> col' a < col' a') as+>           col' (Atom a)       =  col a+>           col' (Paren a _ _)  =  col a+>+> atom                          :: (CToken tok) => Parser (Pos tok) (Atom (Pos tok))+> atom                          =  fmap Atom noSep+>                               `mplus` do l <- left+>                                          e <- chunk+>                                          r <- right l+>                                          return (Paren l e r)++Primitive parser.++> sep, noSep, left              :: (CToken tok) => Parser tok tok+> sep                           =  satisfy (\t -> catCode t == Sep)+> noSep                         =  satisfy (\t -> catCode t == NoSep)+> left                          =  satisfy (\t -> case catCode t of Del c -> c `elem` "(["; _-> False)+> right l                       =  satisfy (\c -> case (catCode l, catCode c) of+>                                      (Del o, Del c) -> (o,c) `elem` zip "([" ")]" +>                                      _     -> False)++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Internal alignment}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++\Todo{Internal alignment Spalte automatisch bestimmen. Vorsicht: die+Position von |=| oder |::| heranzuziehen ist gef"ahrlich; wenn z.B.+|let x = e| in einem |do|-Ausdruck vorkommt.}++> data Line a                   =  Blank+>                               |  Three a a a+>                               |  Multi a+>+> align                         :: (CToken tok) => Maybe Int -> [[Pos tok]] -> [Line [Pos tok]]+> align c                       =  fmap (maybe Multi split3 c)+>   where+>   split3 i ts                 =  case span (\t -> col t < i) ts of+>       ([], [])                -> Blank+>       ((_ : _), [])           -> Multi ts+>       (us, v : vs)+>           | col v == i && isInternal v+>                               -> Three us [v] vs+>           | null us           -> Three [] [] (v : vs)+>           | otherwise         -> Multi ts+>+>+> isInternal                    :: (CToken tok) => tok -> Bool+> isInternal t                  =  case token t of+>     Consym _                  -> True+>     Varsym _                  -> True+>     Special _                 -> True+>     _                         -> False+>+> instance Functor Line where+>     fmap f Blank              =  Blank+>     fmap f (Three l c r)      =  Three (f l) (f c) (f r)+>     fmap f (Multi a)          =  Multi (f a)++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Adding spaces}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Inserting spaces before and after keywords. We use a simple finite+automata with three states: |before b| means before a keyword, |b|+indicates whether to insert a space or not; |after| means immediately+after a keyword (hence |before b| really means not immediately after).++> addSpaces                     :: (CToken tok) => [tok] -> [tok]+> addSpaces ts                  =  before False ts+>     where+>     before b []               =  []+>     before b (t : ts)         =  case token t of+>         u | selfSpacing u     -> t : before False ts+>         Special c+>           | c `elem` ",;([{"  -> t : before False ts+>         Keyword _             -> [ fromToken (TeX sub'space) | b ] ++ t : after ts+>         _                     -> t : before True ts+> +>     after []                  =  []+>     after (t : ts)            =  case token t of+>         u | selfSpacing u     -> t : before False ts+>         Special c+>           | c `elem` ",;([{"  -> fromToken (TeX sub'space) : t : before False ts+>         Keyword _             -> fromToken (TeX sub'space) : t : after ts+>         _                     -> fromToken (TeX sub'space) : t : before True ts++Operators are `self spacing'.++> selfSpacing                   :: Token -> Bool+> selfSpacing (Consym _)        =  True+> selfSpacing (Varsym _)        =  True+> selfSpacing (Op _)            =  True+> -- |selfSpacing (TeX _) =  True|+> selfSpacing _                 =  False++\NB It's not a good idea to regard inline \TeX\ as self spacing consider,+for example, a macro like @%format mu = "\mu "@.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Left indentation}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Auch wenn |auto = False| wird der Stack auf dem laufenden gehalten.++> type Stack                    =  [(Col, Doc, [Pos Token])]+>+> leftIndent dict auto (lst, rst)+>                               =  loop lst rst+>   where+>   copy d | auto               =  d+>          | otherwise          =  Empty++Die Funktion |isInternal| pr"uft, ob |v| ein spezielles Symbol wie+@::@, @=@ etc~oder ein Operator wie @++@ ist.++>   loop lst rst []             =  (Empty, (lst, rst))+>   loop lst rst (l : ls)       =  case l of+>       Blank                   -> loop lst rst ls+>       Three l c r             -> (sub'column3 (copy lskip <> latexs dict l)+>                                               (latexs dict c)+>                                               (copy rskip <> latexs dict r) <> sep ls <> rest, st')+>           where (lskip, lst') =  indent l lst+>                 (rskip, rst') =  indent r rst+>                 (rest, st')   =  loop lst' rst' ls -- does not work: |if null l && null c then rst' else []|+>       Multi m                 -> (sub'column1 (copy lskip <> latexs dict m) <> sep ls <> rest, st')+>           where (lskip, lst') =  indent m lst+>                 (rest, st')   =  loop lst' [] ls+>+>   sep []                      =  Empty+>   sep (Blank : _ )            =  sub'blankline+>   sep (_ : _)                 =  sub'nl+>+>   indent                      :: [Pos Token] -> Stack -> (Doc, Stack)+>   indent [] stack             =  (Empty, stack)+>   indent ts@(t : _) []        =  (Empty, [(col t, Empty, ts)])+>   indent ts@(t : _) (top@(c, skip, line) : stack)+>                               =  case compare (col t) c of+>       LT                      -> indent ts stack+>       EQ                      -> (skip, (c, skip, ts) : stack)+>       GT                      -> (skip', (col t, skip', ts) : top : stack)+>           where+>           skip'               =  case span (\u -> col u < col t) line of+>               (us, v : vs) | col v == col t+>                               -> skip <> sub'phantom (latexs dict us)+>               -- does not work: |(us, _) -> skip ++ [Phantom (fmap token us), Skip (col t - last (c : fmap col us))]|+>               _               -> skip <> sub'hskip (Text em)+>                   where em    =  showFFloat (Just 2) (0.5 * fromIntegral (col t - c) :: Double) ""++M"ussen |v| und |t| zueinander passen?+%+\begin{verbatim}+where |a      =    where |Str c =    [    [    (    {+      |(b, c) =          |c@(..)=    ,    |    ,    ;+                                     ]    ]    )    }+\end{verbatim}+
+ MathCommon.lhs view
@@ -0,0 +1,219 @@+%-------------------------------=  --------------------------------------------+\subsection{Common code for math and poly formatters}+%-------------------------------=  --------------------------------------------++ks, 15.06.2004: I have moved common code from the math and poly formatters+to this module. Poly has been created from a copy of the old math formatter,+therefore there has been much overlap between the two modules.++> module MathCommon             (  module MathCommon  )+> where++> import Typewriter ( latex )+> import Document+> import Directives+> import HsLexer+> import qualified FiniteMap as FM+> import Auxiliaries++> when True f                   =  f+> when False f                  =  return++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Adding positional information}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> type Row                      =  Int+> type Col                      =  Int+>+> data Pos a                    =  Pos {row :: !Row, col :: !Col, ann :: a}+>                                  deriving (Show)++%{+%format r1+%format r2+%format c1+%format c2++> instance Eq (Pos a) where+>     Pos r1 c1 _ == Pos r2 c2 _=  r1 == r2 && c1 == c2+> instance Ord (Pos a) where+>     Pos r1 c1 _ <= Pos r2 c2 _=  (r1, c1) <= (r2, c2)++%}++> instance (CToken tok) => CToken (Pos tok) where+>     catCode (Pos _ _ t)       =  catCode t+>     token (Pos _ _ t)         =  token t+>     inherit (Pos r c t') t    =  Pos r c (inherit t' t)+>     fromToken t               =  Pos 0 0 (fromToken t)++Numbering the list of tokens.++> number                        :: Row -> Col -> [Token] -> [Pos Token]+> number r c []                 =  []+> number r c (t : ts)           =  Pos r c t : number r' c' ts+>     where (r', c')            =  count r c (string t)+>+> count                         :: Row -> Col -> String -> (Row, Col)+> count r c []                  =  (r, c)+> count r c (a : s)+>     | a == '\n'               =  count (r + 1) 1       s+>     | otherwise               =  count r       (c + 1) s++Splitting the token list in lines.++> lines                         :: [Pos a] -> [[Pos a]]+> lines                         =  split 1+>     where+>     split _   []              =  []+>     split r ts                =  us : split (r + 1) vs+>         where (us, vs)        =  span (\t -> row t <= r) ts++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{A very simple Haskell Parser}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++ks, 27.06.2003: I'll add some explanation which reflects the way I understand+things. Since I don't know Smugweb and I haven't written the code below, it is+possible that the explanation is not adequate:++A |Chunk| is a sequence of \emph{delimiters} or \emph{applications}. Delimiters+are keywords or operators. Applications are everything else. ++An |application| is a sequence of atoms that are forming a Haskell +function application. The list must never be empty, but can contain+a single element (for instance, in normal infix expressions such as |2 + 3|+this will occur frequently).++An |atom| is a single identifier (not an operator, though -- those are+delimiters), or a chunk in parentheses.++> type Chunk a                  =  [Item a]+>+> data Item a                   =  Delim a+>                               |  Apply [Atom a]+>                                  deriving (Show)+>+> data Atom a                   =  Atom a+>                               |  Paren a (Chunk a) a+>                                  deriving (Show)++The parser itself differs between the two styles. The math formatter+cannot handle unbalanced parentheses, the poly formatter has a heuristic+that allows successful parsing of unbalanced parentheses in many, but+not all cases.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Making replacements}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> data Mode                     =  Mandatory+>                               |  Optional Bool++If |eval e| returns |Mandatory| then parenthesis around |e| must not be+dropped; |Optional True| indicates that it can be dropped; |Optional+False| indicates that the decision is up the caller.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Making replacements}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++ks, 23.07.2003: This substitute function does not work recursively.+To change this is on my TODO list. Substitutions without arguments,+hovewer, do work recursively because they are handled again at a later+stage (by the call to latexs, for instance in leftIndent).++> substitute                    :: (CToken tok,Show tok) => Formats -> Bool -> Chunk tok -> [tok]+> substitute d auto chunk       =  snd (eval chunk)+>   where+>   eval                        :: (CToken tok) => [Item tok] -> (Mode,[tok])+>   eval [e]                    =  eval' e+>   eval chunk                  =  (Optional False, concat [ snd (eval' i) | i <- chunk ])+>+>   eval'                       :: (CToken tok) => Item tok -> (Mode,[tok])+>   eval' (Delim s)             =  (Optional False, [s])+>   eval' (Apply [])            =  impossible "eval'"+>   eval' (Apply (e : es))      =  eval'' False e es+>+>   eval''                      :: (CToken tok) => Bool -> Atom tok -> [Atom tok] -> (Mode,[tok])+>   eval'' _ (Atom s) es        =  case FM.lookup (string (token s)) d of+>     Nothing                   -> (Optional False, s : args es)+>     Just (opt, opts, lhs, rhs)-> (Optional opt, set s (concat (fmap sub rhs)) ++ args bs)+>         where+>         (as, bs) | m <= n     =  (es ++ replicate (n - m) dummy, [])+>                  | otherwise  =  splitAt n es+>         n                     =  length lhs+>         m                     =  length es+>         binds                 =  zip lhs [ snd (eval'' b a []) | (b, a) <- zip opts as ]+>         sub t@(Varid x)       =  case FM.lookup x (FM.fromList binds) of+>             Nothing           -> [fromToken t]+>             Just ts           -> ts+>         sub t                 =  [fromToken t]++Whenever a token is replaced or removed, the first token of the replacement+inherits the position of the original token.++>   eval'' opt (Paren l e r) es+>       | optional              =  (Mandatory, set l s ++ args es)+>       | otherwise             =  (Optional False, [l] ++ s ++ [r] ++ args es)+>       where (flag, s)         =  eval e+>             optional          =  catCode l == Del '(' && not (mandatory e)+>                               && case flag of Mandatory -> False; Optional f -> opt || f++\NB It is not a good idea to remove parentheses around atoms, because+that would remove the parentheses in @deriving (Eq)@ and @module M (a)@+as well.++>   args                        :: (CToken tok) => [Atom tok] -> [tok]+>   args es                     =  concat [ sp ++ snd (eval'' False i []) | i <- es ] -- $\cong$ Applikation+>   sp                          :: (CToken tok) => [tok]+>   sp | auto                   =  [fromToken (TeX sub'space)]+>      | otherwise              =  []++To support macros of the form @%format Parser (a) = a@.++> set                           :: (CToken tok) => tok -> [tok] -> [tok]+> set s []                      =  []+> set s (t : ts)                =  inherit s (token t) : ts+>+> mandatory                     :: (CToken tok) => Chunk tok -> Bool+> mandatory e                   =  False++Code before:++< mandatory e                   =  null e               -- nullary tuple+<                               || or [ isComma i | i <- e ] -- tuple+<                               || isOp (head e)        -- left section+<                               || isOp (last e)        -- right section++> isComma, isOp                 :: (CToken tok) => Item tok -> Bool+> isComma (Delim t)             =  case token t of+>     Special c                 -> c == ','+>     _                         -> False+> isComma _                     =  False+>+> isOp (Delim t)                =  case token t of+>     Special c                 -> c == '`'     -- f"ur @` div `@+>     Consym _                  -> True+>     Varsym s                  -> s /= "\\"+>     Op _                      -> True+>     _                         -> False+> isOp _                        =  False++> dummy                         :: (CToken tok) => Atom tok+> dummy                         =  Atom (fromToken (Varid ""))++\NB We cannot use embedded \TeX\ text here, because |TeX| is not a+legal atom (|string| is applied to it).++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Adding spaces and indentation}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++There are subtle differences between the two styles.++For inline-code.++> latexs                        :: (CToken tok) => Formats -> [tok] -> Doc+> latexs dict                   =  catenate . fmap (latex sub'space sub'space dict . token)
+ MathPoly.lhs view
@@ -0,0 +1,407 @@+%-------------------------------=  --------------------------------------------+\subsection{Poly formatter}+%-------------------------------=  --------------------------------------------++ks, 28.07.2003: This is a new style that is based on the old @math@-style+and is intended to replace @math@ style in a future version. Because the+former @math@ style should remain compatible, I've copied the entire module.+Essentially, there are the same functions here doing the same job, but there+are subtle differences, and they will grow over time \dots++%if codeOnly || showModuleHeader++> module MathPoly               (  module MathPoly, substitute, number  )+> where+>+> import Prelude hiding         (  lines )+> import Data.List              (  partition, nub, insert, sort, transpose )+> import Numeric                (  showFFloat )+> import Control.Monad          (  MonadPlus(..) )+>+> import Verbatim               (  expand, trim )+> import Typewriter             (  latex )+> import MathCommon+> import Document+> import Directives+> import HsLexer+> import Parser+> import qualified FiniteMap as FM+> import Auxiliaries+> -- import Debug.Trace ( trace )++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline                        :: Formats -> Bool -> String -> Either Exc Doc+> inline fmts auto              =  fmap unNL+>                               .> tokenize+>                               @> lift (number 1 1)+>                               @> when auto (lift (filter (isNotSpace . token)))+>                               @> lift (partition (\t -> catCode t /= White))+>                               @> exprParse *** return+>                               @> lift (substitute fmts auto) *** return+>                               @> lift (uncurry merge)+>                               @> lift (fmap token)+>                               @> when auto (lift addSpaces)+>                               @> lift (latexs fmts)+>                               @> lift sub'inline++> display                       :: Formats -> Bool -> Int -> Int -> Stack+>                               -> String -> Either Exc (Doc, Stack)+> display fmts auto sep lat stack+>                               =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize+>                               @> lift (number 1 1)+>       --                     |@> when auto (lift (filter (isNotSpace . token)))|+>                               @> lift (partition (\t -> catCode t /= White))+>                               @> exprParse *** return+>                               @> lift (substitute fmts auto) *** return+>                               @> lift (uncurry merge)+>                               @> lift lines+>                               @> when auto (lift (fmap addSpaces))+>                               @> lift (\ts -> (autoalign sep ts,ts))+>       --                     |@> lift (\(x,y) -> trace ((unlines $ map show $ y) ++ "\n" ++ show x) (x,y))|+>                               @> lift (\(cs,ts) -> let ats = align cs sep lat ts+>                                                        cs' = [("B",0)] ++ cs +>                                                           ++ [("E",error "E column")]+>                                                    in  (autocols cs' ats,ats)+>                                       )+>                               @> return *** when auto (lift (fmap (fmap (filter (isNotSpace . token)))))+>       --                     |@> return *** when auto (lift (fmap (fmap (addSpaces . filter (isNotSpace . token)))))|+>                               @> lift (\((cs,z),ats) -> (cs,(z,ats)))+>                               @> return *** lift (\(z,ats) -> leftIndent fmts auto z [] ats)+>       -- ks, 17.07.2003: i've changed "stack" into "[]" and thereby disabled+>       -- the global stack for now as it leads to unexepected behaviour+>                               @> lift (\(cs,(d,stack)) -> (sub'code (columns cs <> d),stack))+>+> columns                       :: [(String,Doc)] -> Doc+> columns                       =  foldr (<>) Empty +>                               .  map (uncurry sub'column)++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{A very simple Haskell Parser}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++The parser is based on the Smugweb parser.+This variant can handle unbalanced parentheses in some cases (see below).++> exprParse                     :: (CToken tok, Show tok) => [Pos tok] -> Either Exc (Chunk (Pos tok))+> exprParse s                   =  case run (chunk 0) s of+>     Nothing                   -> Left ("syntax error", show s) -- HACK: |show s|+>     Just e                    -> Right e+>+> chunk                         :: (CToken tok) => Int -> Parser (Pos tok) (Chunk (Pos tok))+> chunk d                       =  do a <- many (atom d)+>                                     as <- many (do s <- sep; a <- many (atom d); return ([Delim s] ++ offside a))+>                                     return (offside a ++ concat as)+>     where offside []          =  []+>           -- old: |opt a =  [Apply a]|+>           offside (a : as)    =  Apply (a : bs) : offside cs+>               where (bs, cs)  =  span (\a' -> col' a < col' a') as+>           col' (Atom a)       =  col a+>           col' (Paren a _ _)  =  col a+>+> atom                          :: (CToken tok) => Int -> Parser (Pos tok) (Atom (Pos tok))+> atom d                        =  fmap Atom noSep+>                               `mplus` do l <- left+>                                          e <- chunk (d+1)+>                                          r <- right l+>                                          return (Paren l e r)+>                               `mplus` if d == 0 then do r <- anyright+>                                                         return (Paren (fromToken $ TeX Empty) [] r)+>                                                 else mzero++ks, 09.09.2003: Added handling of unbalanced parentheses, surely not in the+most elegant way. Both |chunk| and |atom| now take an integer argument+indicating the nesting level. Only on the top-level unbalanced right+parentheses are accepted. The end of file (end of code block) can be+parsed as an arbitrary amount of right parentheses.++Primitive parser.++> sep, noSep, left, anyright    :: (CToken tok) => Parser tok tok+> sep                           =  satisfy (\t -> catCode t == Sep)+> noSep                         =  satisfy (\t -> catCode t == NoSep)+> left                          =  satisfy (\t -> case catCode t of Del c -> c `elem` "(["; _ -> False)+> anyright                      =  satisfy (\t -> case catCode t of Del c -> c `elem` ")]"; _ -> False)+> right l                       =  (satisfy (\c -> case (catCode l, catCode c) of+>                                       (Del o, Del c) -> (o,c) `elem` zip "([" ")]" +>                                       _     -> False)+>                                  ) `mplus` do eof+>                                               return (fromToken $ TeX Empty)++ks, 06.09.2003: Modified the |right| parser to accept the end of file,+to allow for unbalanced parentheses. This behaviour is not (yet) backported+to |math| style. Also added |anyright|.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Internal alignment}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> data Line a                   =  Blank+>                               |  Poly  [((String,Int),a,Bool)]+>+> autoalign                     :: (Show tok,CToken tok) => Int              -- "Trennung"+>                                               -> [[Pos tok]]      -- positionierte tokens per Zeile+>                                               -> [(String,Int)]   -- alignment-info (Name, Spalte)+> autoalign sep toks            =  map (\x -> (show x,x))+>                               .  nub+>                               .  sort+>                               .  concat +>                               .  fmap findCols +>                               $  toks+>   where+>   findCols                    :: (CToken tok,Show tok) => [Pos tok] -> [Col]+>   findCols ts                 =  case {- |trace (show ts)| -} +>                                       (break (\t -> not . isNotSpace . token $ t) ts) of+>       (_, [])                 -> []   -- done+>       (_, [v])                -> []   -- last token is whitespace, doesn't matter+>       (_, v:v':vs)+>         | row v' == 0 && col v' == 0+>                               -> findCols (v:vs)  -- skip internal tokens (automatically added spaces)+>         | length (string (token v)) >= sep+>                               -> {- |trace ("found: " ++ show (col v')) $| -} col v' : findCols (v':vs)+>         | otherwise           -> {- |trace ("found too short")|            -} findCols (v':vs)++ks, 21.11.2005: I've fixed a bug that was known to me since long ago, but I never got+around to investigate. When a parametrized formatting directive directly precedes a+token that should be aligned, then sometimes that token was not aligned. The reason+was that in |findCols| above, the recursive calls used |vs| instead of |(v':vs)|.++> align                         :: (CToken tok) => [(String,Int)]   -- alignment-info (Name, Spalte)+>                                               -> Int              -- "Trennung"+>                                               -> Int              -- "Traegheit"+>                                               -> [[Pos tok]]      -- positionierte tokens per Zeile+>                                               -> [Line [Pos tok]]+> align cs sep lat toks         =  fmap (\t -> {- |trace (show (map token t) ++ "\n") $| -}+>                                              let res = splitn ("B",0) False cs t+>                                              in  if null [x | x <- t+>                                                          , (row x /= 0 || col x /= 0) && isNotSpace (token x)]+>                                                      || null res +>                                              then Blank+>                                              else Poly res+>                                       ) toks+>   where+>   splitn cc ind [] []         =  []+>   splitn cc ind [] ts         =  [(cc,ts,ind)]+>   splitn cc ind ((n,i):oas) ts=  +>     case span (\t -> col t < i) ts of+>       ([], vs)                -> splitn cc ind oas vs+>       (us, [])                -> [(cc,us,ind)]+>       (us, (v:vs))            -> +>         let lu = head [ u | u <- reverse us, col u /= 0 || row u /= 0 ]+>                                  -- again, we skip automatically added spaces+>             llu = length (string (token lu))+>         in case () of+>             _ | (lat /= 0 && isNotSpace (token lu)) || llu < lat || col v /= i+>                                  -- no alignment for this column+>                               -> splitn cc ind oas (us ++ (v:vs))+>               | not (isNotSpace (token lu)) && llu >= sep+>                               -> (cc,us,ind) : splitn (n,i) True oas (v:vs)+>               | otherwise+>                               -> (cc,us,ind) : splitn (n,i) False oas (v:vs)++Die Funktion |isInternal| pr"uft, ob |v| ein spezielles Symbol wie+@::@, @=@ etc~oder ein Operator wie @++@ ist.++> isInternal                    :: (CToken tok) => tok -> Bool+> isInternal t                  =  case token t of+>     Consym _                  -> True+>     Varsym _                  -> True+>     Special _                 -> True+>     _                         -> False+>+> instance Functor Line where+>     fmap f Blank              =  Blank+>     fmap f (Poly ls)          =  Poly (map (\(x,y,z) -> (x,f y,z)) ls)++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Automatically determining centered columns}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++We use a simple heuristic: a column that contains only single tokens and+at least one ``internal'' token is centered. For centered columns, we create+an additional ``end'' column to make sure that all entries are centered on the+same amount of space.++> autocols                      :: (CToken tok, Show tok) => [(String,Int)]   -- column info+>                                               -> [Line [Pos tok]] -- aligned tokens+>                                               -> ([(String,Doc)],[Col]) -- cols+alignment, plus centered columns+> autocols cs ats               = (\(x,y) -> (concat x,concat y)) $ unzip +>                               $ zipWith3 (\(cn,n) ml ai -> +>                                              if ml <= 2 && ai then ([(cn,sub'centered)+>                                                                     ,(cn ++ "E",sub'dummycol)+>                                                                     ],[n])+>                                                               else ([(cn,sub'left)],[])+>                                          ) cs maxlengths anyinternals+>                                 -- length 2, because space tokens are always there+>     where+>     cts                       = transpose (concatMap (deline cs) ats)+>     maxlengths                = {- |trace (show cts) $ |-} map (maximum . map length) cts+>     anyinternals              = map (or . map (any isInternal)) cts+>+>     -- deline                    :: [(String,Int)] -> Line [a] -> [[[a]]]+>     deline cs Blank           = []+>     deline cs (Poly ls)       = [decol cs ls]+>+>     decol cs []               = replicate (length cs) []+>     decol ((cn,_):cs) r@(((cn',_),ts,_):rs)+>       | cn' == cn             = ts : decol cs rs+>       | otherwise             = [] : decol cs r++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Adding spaces}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Inserting spaces before and after keywords. We use a simple finite+automata with three states: |before b| means before a keyword, |b|+indicates whether to insert a space or not; |after| means immediately+after a keyword (hence |before b| really means not immediately after).++> addSpaces                     :: (CToken tok) => [tok] -> [tok]+> addSpaces ts                  =  before False ts+>     where+>     before b []               =  []+>     before b (t : ts)         =  case token t of+>         u | not (isNotSpace u)-> t : before b ts+>           | selfSpacing u     -> t : before False ts+>         Special c+>           | c `elem` ",;([{"  -> t : before False ts+>         Keyword _             -> [ fromToken (TeX sub'space) | b ] ++ t : after ts+>         _                     -> t : before True ts+> +>     after []                  =  []+>     after (t : ts)            =  case token t of+>         u | not (isNotSpace u)-> t : after ts+>           | selfSpacing u     -> t : before False ts+>         Special c+>           | c `elem` ",;([{"  -> fromToken (TeX sub'space) : t : before False ts+>         Keyword _             -> fromToken (TeX sub'space) : t : after ts+>         _                     -> fromToken (TeX sub'space) : t : before True ts++Operators are `self spacing'.++> selfSpacing                   :: Token -> Bool+> selfSpacing (Consym _)        =  True+> selfSpacing (Varsym _)        =  True+> selfSpacing (Op _)            =  True+> -- |selfSpacing (TeX _) =  True|+> selfSpacing _                 =  False++\NB It's not a good idea to regard inline \TeX\ as self spacing consider,+for example, a macro like @%format mu = "\mu "@.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Left indentation}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++ks, 16.07.2003: Die Bedeutung von |auto| verstehe ich nicht so ganz:+Auch wenn |auto = False| wird der Stack auf dem laufenden gehalten.++ks, 16.07.2003: Ich versuche nun, das folgende relativ einfache+Einrueckungsverhalten zu implementieren -- aus meiner bisherigen Erfahrung+mit dem @poly@-style heraus habe ich den Eindruck, als muesste das+weitgehend genuegen. Ansonsten kann man ja immer noch explizit die+Einrueckung mit Annotationen formatieren.++> type Stack                    =  [(Col, Line [Pos Token])]++Der Stack besteht also aus einer Liste von Paaren aus Spaltennummern+und Token. Der Kopf der Liste hat die hoechste Spaltennummer, und die+Spaltennummern in der Liste sind absteigend.++Einrueckung findet immer am Beginn einer neuen Zeile statt, wobei+die Position des ersten Tokens in der Zeile relevant ist.+Als erstes wird der Stack adjustiert: alle Elemente, die hoehere+oder gleiche Spaltennummern haben als die augenblickliche Zeile, +werden entfernt.++Dann wird in dem nun obersten Stackelement nach dem letzten Token+gesucht, das eine Spaltenposition kleiner oder gleich dem aktuellen+Element hat. Bezueglich diesem wird nun eingerueckt.+Achtung: Derzeit findet das \emph{immer} statt. Das ist vielleicht+keine so gute Idee, aber mir fallen nur wenige Situationen ein,+in denen es von Schaden waere.++Letztlich wird die augenblickliche Zeile auf den Stack gelegt.++> leftIndent                    :: Formats -> Bool +>                               -> [Col]        -- zentrierte Spalten+>                               -> Stack        -- augenblicklicher Stack+>                               -> [Line [Pos Token]]+>                               -> (Doc, Stack)+> leftIndent dict auto z stack+>                               =  loop True stack+>   where+>   copy d | auto               =  d+>          | otherwise          =  Empty++>   loop                        :: Bool -> Stack -> [Line [Pos Token]] -> (Doc, Stack)+>   loop first stack []         =  (Empty, stack)  -- fertig+>   loop first stack (l:ls)     =  case l of+>       Blank                   -> loop True stack ls -- Leerzeilen ignorieren+>    {-| Poly x || trace (show x) False -> undefined |-}+>       Poly []                 -> loop True stack ls -- naechste Zeile+>       Poly (((n,c),[],ind):rs)+>         | first               -> loop True stack (Poly rs:ls) -- ignoriere leere Spalten zu Beginn+>       Poly p@(((n,c),ts,ind):rs)+>         | first               -> -- ueberpruefe Einrueckung:+>                                  let -- Schritt 1: Stack verkleinern+>                                      rstack  = dropWhile (\(rc,_) -> rc >= c) stack+>                                      -- Schritt 2: relevante Spalte finden+>                                      (rn,rc) = findrel (n,c) rstack+>                                      -- Schritt 3: Zeile auf Stack legen+>                                      fstack  = (c,l) : rstack+>                                  in mkFromTo fstack rn n rc [fromToken $ TeX (indent (rn,rc) (n,c))] p ls+>                                              +>+>         | c `elem` z          -> mkFromTo stack n (n ++ "E") c ts rs ls+>                                                     -- zentrierte Spalten gesondert behandeln+>       Poly [((n,c),ts,ind)]   -> mkFromTo stack n "E" c ts [] ls+>                                                     -- letzte Spalten+>       Poly (((n,c),ts,ind):rs@(((nn,_),_,_):_))+>                               -> mkFromTo stack n nn  c ts rs ls +>+>   mkFromTo stack bn en c ts rs ls+>     | bn == en                =  -- dies kann am Beginn einer Zeile durch Einrueckung passieren+>                                  (rest,stack')+>     | otherwise               =  (sub'fromto bn en (latexs dict ts)+>                                     <> (if null rs then sep ls else Empty) <> rest+>                                  ,stack'+>                                  )+>     where+>       (rest,stack')           =  loop False  -- not first of a line+>                                       stack+>                                       (Poly rs : ls)+>+>+>   findrel                     :: (String,Col) -> Stack -> (String,Col)+>   findrel (n,c) []            =  (n,c)+>   findrel (n,c) ((_,Blank):r) =  findrel (n,c) r  -- should never happen+>   findrel (n,c) ((_,Poly t):_)+>                               =  case break (\((n',c'),_,_) -> c' > c) t of+>                                    ([],_)     -> error "findrel: the impossible happened"+>                                    (pre,_)    -> let ((rn,rc),_,_) = last pre+>                                                  in  (rn,rc)+>+>   sep []                      =  Empty+>   sep (Blank : _ )            =  sub'blankline+>   sep (_ : _)                 =  sub'nl+>+>   indent                      :: (String,Int) -> (String,Int) -> Doc+>   indent (n,c) (n',c')+>     | c /= c'                 =  (sub'indent (Text (show (c' - c))))+>     | otherwise               =  Empty++M"ussen |v| und |t| zueinander passen?+%+\begin{verbatim}+where |a      =    where |Str c =    [    [    (    {+      |(b, c) =          |c@(..)=    ,    |    ,    ;+                                     ]    ]    )    }+\end{verbatim}+
+ NewCode.lhs view
@@ -0,0 +1,102 @@+%-------------------------------=  --------------------------------------------+\subsection{New code formatter}+%-------------------------------=  --------------------------------------------++This is a more sophisticated code formatter that respects formatting+directives.++It should even respect formatting directives with arguments, in a+way that is compatible with the @poly@ or @math@ formatters.++%if codeOnly || showModuleHeader++> module NewCode                (  module NewCode  )+> where+>+> import Data.List              (  partition )+>+> import Verbatim               (  trim, expand )+> import Document+> import Directives+> import HsLexer+> import qualified FiniteMap as FM+> import Auxiliaries+> import MathPoly               (  exprParse, substitute, number )++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++\NB We do not need an |inline| function because we are only interested+in the ``real'' program code. All comments are deleted.++> display                       :: Formats -> String -> Either Exc Doc+> display fmts                  =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize+>                               @> lift (number 1 1)+>                               @> lift (partition (\t -> catCode t /= White))+>                               @> exprParse *** return+>                               @> lift (substitute fmts False) *** return+>                               @> lift (uncurry merge)+>                               @> lift (fmap token)+>                               @> lift (latexs sub'space sub'nl fmts)+>                               @> lift sub'code++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Encoding}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++ks, added 10.01.2004:+This is based on |latexs| in Typewriter, and therefore still named+this way, but it is a bit simpler and does not use anything \LaTeX ish:+the |latexs| and |latex| functions itself are copied literally, but+|convert| does not do anything except replacing newlines and spaces,+if specified by an appropriate @%subst@. It's questionable whether this+functionality is actually desired.++> latexs                        :: Doc -> Doc -> Formats -> [Token] -> Doc+> latexs sp nl dict             =  catenate . map (latex sp nl dict)+>+> latex                         :: Doc -> Doc -> Formats -> Token -> Doc+> latex sp nl dict              =  tex Empty+>     where+>     tex _ (Space s)           =  sub'spaces (convert s)+>     tex q (Conid s)           =  replace q s (sub'conid (q <> convert s))+>     tex _ (Varid "")          =  sub'dummy    -- HACK+>     tex q (Varid s)           =  replace q s (sub'varid (q <> convert s))+>     tex q (Consym s)          =  replace q s (sub'consym (q <> convert s))+>     tex q (Varsym s)          =  replace q s (sub'varsym (q <> convert s))+>     tex _ (Numeral s)         =  replace Empty s (sub'numeral (convert s)) -- NEU+>     tex _ (Char s)            =  sub'char (catenate (map conv (init $ tail s))) -- NEW: remove quotes+>     tex _ (String s)          =  sub'string (catenate (map conv (init $ tail s))) -- NEW: remove quotes+>     tex _ (Special c)         =  sub'special (replace Empty [c] (conv c))+>     tex _ (Comment s)         =  sub'comment (convert s)+>     tex _ (Nested s)          =  sub'nested (convert s)+>     tex _ (Pragma s)          =  sub'pragma (convert s)+>     tex _ (Keyword s)         =  replace Empty s (sub'keyword (convert s))+>     tex _ (TeX d)             =  d+>     tex _ t@(Qual ms t')      =  replace Empty (string t) (tex (catenate (map (\m -> tex Empty (Conid m) <> Text ".") ms)) t')+>     tex _ t@(Op t')           =  replace Empty (string t) (cmd (conv '`' <> tex Empty t' <> conv '`'))+>         where cmd | isConid t'=  sub'consym+>                   | otherwise =  sub'varsym+>+>     replace q s def           =  case FM.lookup s dict of+>         Just (_, _, [], ts)   -> q <> catenate (map (tex Empty) ts)+>         _                     -> def++\NB the directives @%format a = b@ and @%format b = a@ cause a loop.+ +\NB Only nullary macros are applied.++Conversion of strings and characters.++>     convert                   :: String -> Doc+>     convert s                 =  catenate (map conv s)+>     conv                      :: Char -> Doc+>     conv ' '                  =  sp+>     conv '\n'                 =  nl+>     conv c                    =  Text [c]+
+ Parser.lhs view
@@ -0,0 +1,85 @@+%-------------------------------=  --------------------------------------------+\subsection{Deterministic parser}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Parser                 (  Parser, run, satisfy, lit, lits, wrap, nonnull, eof  )+> where+>+> import Data.Char              (  isSpace  )+> import Auxiliaries+> import Control.Monad          (  MonadPlus(..), filterM  )++%endif+Deterministische Mini-Parser.+%if style == math+%format (MkParser (p)) = p+%format (unParser (p)) = p+%else++> unParser (MkParser p)         =  p++%endif++> newtype Parser tok a          =  MkParser ([tok] -> Maybe (a, [tok]))+>+> run                           :: Parser tok a -> [tok] -> Maybe a+> run (MkParser p) inp          =  fmap fst (p inp)+>+> instance Functor (Parser tok) where+>     fmap f m                  =  m >>= \a -> return (f a)+> instance Monad (Parser tok) where+>     return a                  =  MkParser (\inp -> Just (a, inp))+>     m >>= k                   =  MkParser (\inp -> case unParser m inp of+>                                      Nothing        -> Nothing+>                                      Just (a, rest) -> unParser (k a) rest)+> instance MonadPlus  (Parser tok) where+>     mzero                     =  MkParser (\inp -> Nothing)+>     m `mplus` n               =  MkParser (\inp -> unParser m inp `mplus` unParser n inp)+>+> satisfy                       :: (tok -> Bool) -> Parser tok tok+> satisfy pred                  =  MkParser (\inp -> case inp of+>                                      a : rest | pred a -> Just (a, rest)+>                                      _                 -> Nothing)+>+> lit                           :: (Eq tok) => tok -> Parser tok tok+> lit c                         =  satisfy (== c)++ks, 06.09.2003: Adding eof that accepts succeeds only at the end of input.++> eof                           :: Parser tok ()+> eof                           =  MkParser (\inp -> case inp of+>                                      []                -> Just ((),[])+>                                      _                 -> Nothing)++|lits s| corresponds to |mapM_ lit_ s|.++> lits                          :: (Eq tok) => [tok] -> Parser tok ()+> lits s                        =  MkParser (\inp -> case splitAt (length s) inp of+>                                      (s', rest) | s == s' -> Just ((), rest)+>                                      _                    -> Nothing)++\Todo{Better name for |wrap|.}++> wrap                          :: ([tok] -> (a, [tok])) -> Parser tok a+> wrap f                        =  MkParser (\inp -> Just (f inp))+>+> nonnull                       :: ([tok] -> ([a], [tok])) -> Parser tok [a]+> nonnull f                     =  mfilter (not . null) (wrap f)++> mfilter p m                   =  m >>= \a -> if p a then return a else mzero++%if False++> {-+> lit_                          :: (Eq tok) => tok -> Parser tok ()+> lit_ c                        =  MkParser (\inp -> case inp of+>                                      c' : rest | c == c' -> Just ((), rest)+>                                      _                   -> Nothing)+> nonnull_ f                    =  MkParser (\inp -> case f inp of+>                                      res@((_ : _) ,_) -> Just res+>                                      _                -> Nothing)+> -}++%endif
+ RELEASE view
@@ -0,0 +1,56 @@++                     lhs2TeX version 1.12+                     ====================++We are pleased to announce a new release of lhs2TeX, +a preprocessor to generate LaTeX code from literate Haskell+sources.++lhs2TeX includes the following features:++* Highly customized output.++* Liberal parser -- no restriction to Haskell 98.++* Generate multiple versions of a program or document from +  a single source.++* Active documents: call Haskell to generate parts of the +  document (useful for papers on Haskell).++* A manual explaining all the important aspects of lhs2TeX.++Changes (w.r.t. lhs2TeX 1.11)+-----------------------------++* Compatible with ghc-6.6.++* Compatible with cabal-1.1.6; traditional configure/make+  installation should still work. Thanks to Brian Smith+  for submitting a patch to improve the Cabal experience+  on Windows.++Requirements and Download+-------------------------++A source distribution is available from++  http://www.iai.uni-bonn.de/~loeh/lhs2tex/++It has been verified to build on Linux and MacOSX, but+should also work on Windows. Binaries will be made available+on request.++You need a recent version of GHC (6.4.2 is tested, older versions+might work) to build lhs2TeX, and, of course, you need a TeX+distribution to make use of lhs2TeX's output. The program includes+a configuration that is suitable for use with LaTeX. In theory, +there should be no problem to generate code for other TeX +flavors, such as plainTeX or ConTeXt.+++  Happy lhs2TeXing,+  Andres Loeh and Ralf Hinze++  lhs2TeX@andres-loeh.de+  ralf@informatik.uni-bonn.de
+ Setup.hs view
@@ -0,0 +1,379 @@+import Distribution.Setup (CopyDest(..),ConfigFlags(..),BuildFlags(..),+                           CopyFlags(..),RegisterFlags(..),InstallFlags(..))+import Distribution.Simple+import Distribution.Simple.Utils (die,rawSystemExit,maybeExit,copyFileVerbose)+import Distribution.Simple.LocalBuildInfo (LocalBuildInfo(..),mkDataDir,substDir,absolutePath)+import Distribution.Simple.Configure (configCompilerAux)+import Distribution.PackageDescription (PackageDescription(..),setupMessage)+import Distribution.Program (Program(..),ProgramConfiguration(..),+                             ProgramLocation(..),simpleProgram,lookupProgram,+                             rawSystemProgramConf)+-- import Distribution.Compat.ReadP (readP_to_S)+import Data.Char (isSpace, showLitChar)+import Data.List (isSuffixOf,isPrefixOf)+import Data.Maybe (listToMaybe,isJust)+import Control.Monad (when,unless)+import Text.Regex (matchRegex,matchRegexAll,mkRegex,mkRegexWithOpts,subRegex)+import Text.ParserCombinators.ReadP (readP_to_S)+import System.Exit+import System.IO (hGetContents,hClose,hPutStr,stderr)+import System.IO.Error (try)+import System.Process (runInteractiveProcess,waitForProcess)+import System.Directory+import System.Info (os)+  ++lhs2tex = "lhs2TeX"+minPolytableVersion = [0,8,2]+shortversion = show (numversion `div` 100) ++ "." ++ show (numversion `mod` 100)+version = shortversion ++ if ispre then "pre" ++ show pre else ""+numversion = 112+ispre = False+pre = 3++main = defaultMainWithHooks lhs2texHooks++lhs2texBuildInfoFile :: FilePath+lhs2texBuildInfoFile = "." `joinFileName` ".setup-lhs2tex-config"++generatedFiles = ["Version.lhs","lhs2TeX.1",+                  "doc" `joinFileName` "InteractiveHugs.lhs",+                  "doc" `joinFileName` "InteractivePre.lhs"]++data Lhs2texBuildInfo =+  Lhs2texBuildInfo { installPolyTable      ::  Maybe String,+                     rebuildDocumentation  ::  Bool }+  deriving (Show, Read)++lhs2texHooks = defaultUserHooks+                 { hookedPrograms = [simpleProgram "hugs",+                                     simpleProgram "kpsewhich",+                                     simpleProgram "pdflatex",+                                     simpleProgram "mktexlsr"],+                   confHook       = lhs2texConfHook,+                   postConf       = lhs2texPostConf,+                   postBuild      = lhs2texPostBuild,+                   postCopy       = lhs2texPostCopy,+                   postInst       = lhs2texPostInst,+                   regHook        = lhs2texRegHook,+                   cleanHook      = lhs2texCleanHook+                 }++lhs2texConfHook pd cf =+    do  -- give status message+        setupMessage "Pre-Configuring" pd+        comp <- configCompilerAux (cf { configVerbose = 0 })+        let flavor = compilerFlavor comp+        let ver = compilerVersion comp+        pd <- if flavor == GHC && +                 withinRange ver (EarlierVersion (Version [6,5] []))+              then do+                     when (configVerbose cf > 0) $ putStrLn "configure: adapting for ghc < 6.5"+                     return (pd { buildDepends =+                                  filter (\ (Dependency d _) -> d /= "regex-compat") (buildDepends pd) })+              else return pd+        confHook defaultUserHooks pd cf++lhs2texPostConf a cf pd lbi =+    do  -- check polytable+        (_,b,_) <- runKpseWhichVar "TEXMFLOCAL"+        b       <- return . stripQuotes . stripNewlines $ b+        ex      <- return (not . all isSpace $ b) -- or check if directory exists?+        b       <- if ex then return b+                         else do  (_,b,_) <- (runKpseWhichVar "TEXMFMAIN")+                                  return . stripQuotes . stripNewlines $ b+        ex      <- return (not . all isSpace $ b) -- or check if directory exists?+        i       <- if ex then +                   do  (_,p,_) <- runKpseWhich "polytable.sty"+                       p       <- return . stripNewlines $ p+                       ex      <- doesFileExist p+                       nec     <- if ex then do  message $ "Found polytable package at: " ++ p+                                                 x  <- readFile p+                                                 let vp = do  vs <- matchRegex (mkRegexWithOpts " v(.*) .polytable. package" True True) x+                                                              listToMaybe [ r | v <- vs, (r,"") <- readP_to_S parseVersion v ]+                                                 let (sv,nec) = case vp of+                                                                  Just n  -> (showVersion n,versionBranch n < minPolytableVersion)+                                                                  Nothing -> ("unknown",True)+                                                 message $ "Package polytable version: " ++ sv+                                                 return nec+                                        else return True+                       message $ "Package polytable installation necessary: " ++ showYesNo nec+                       when nec $ message $ "Using texmf tree at: " ++ b+                       return (if nec then Just b else Nothing)+                   else+                   do  message "No texmf tree found, polytable package cannot be installed"+                       return Nothing+        -- check documentation+        ex      <- doesFileExist $ "doc" `joinFileName` "Guide2.dontbuild"+        r       <- if ex then do message "Documentation will not be rebuilt unless you remove the file \"doc/Guide2.dontbuild\""+                                 return False+                         else do mProg <- lookupProgram "pdflatex" (withPrograms lbi)+                                 case mProg of+                                   Nothing  -> message "Documentation cannot be rebuilt without pdflatex" >> return False+                                   Just _   -> return True+        unless r $ message $ "Using pre-built documentation"+        writePersistLhs2texBuildConfig (Lhs2texBuildInfo { installPolyTable = i, rebuildDocumentation = r })+        mapM_ (\f -> do message $ "Creating " ++ f+                        hugsExists <- lookupProgram "hugs" (withPrograms lbi)+                        hugs <- case hugsExists of+                                  Nothing -> return ""+                                  Just _  -> fmap fst (getProgram "hugs" (withPrograms lbi))+                        let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+                        let lhs2texBin = lhs2texDir `joinFileName` lhs2tex+                        readFile (f ++ ".in") >>= return .+                                                  -- these paths could contain backslashes, so we+                                                  -- need to escape them.+                                                  replace "@prefix@"  (escapeChars $ prefix lbi) .+                                                  replace "@datadir@" (escapeChars $ absolutePath pd lbi NoCopyDest (datadir lbi)) .+                                                  replace "@LHS2TEX@" lhs2texBin .+                                                  replace "@HUGS@" hugs .+                                                  replace "@VERSION@" version .+                                                  replace "@SHORTVERSION@" shortversion .+                                                  replace "@NUMVERSION@" (show numversion) .+                                                  replace "@PRE@" (show pre) >>= writeFile f)+              generatedFiles+        return ExitSuccess+  where runKpseWhich v = runCommandProgramConf 0 "kpsewhich" (withPrograms lbi) [v]+        runKpseWhichVar v = runKpseWhich $ "-expand-var='$" ++ v ++ "'"++lhs2texPostBuild a bf@(BuildFlags { buildVerbose = v }) pd lbi =+    do  ebi <- getPersistLhs2texBuildConfig+        let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+        let lhs2texBin = lhs2texDir `joinFileName` lhs2tex+        let lhs2texDocDir = lhs2texDir `joinFileName` "doc"+        callLhs2tex v lbi ["--code", "lhs2TeX.sty.lit"] (lhs2texDir `joinFileName` "lhs2TeX.sty")+        callLhs2tex v lbi ["--code", "lhs2TeX.fmt.lit"] (lhs2texDir `joinFileName` "lhs2TeX.fmt")+        createDirectoryIfMissing True lhs2texDocDir+        if rebuildDocumentation ebi then lhs2texBuildDocumentation a bf pd lbi+                                    else copyFileVerbose v ("doc" `joinFileName` "Guide2.pdf") (lhs2texDocDir `joinFileName` "Guide2.pdf")+        return ExitSuccess++lhs2texBuildDocumentation a (BuildFlags { buildVerbose = v }) pd lbi =+    do  let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+        let lhs2texBin = lhs2texDir `joinFileName` lhs2tex+        let lhs2texDocDir = lhs2texDir `joinFileName` "doc"+        snippets <- do  guide <- readFile $ "doc" `joinFileName` "Guide2.lhs"+                        let s = matchRegexRepeatedly (mkRegexWithOpts "^.*input\\{(.*)\\}.*$" True True) guide+                        return s+        mapM_ (\s -> do  let snippet = "doc" `joinFileName` (s ++ ".lhs")+                         c <- readFile $ snippet+                         let inc = maybe ["poly"] id (matchRegex (mkRegexWithOpts "^%include (.*)\\.fmt" True True) c)+                         -- rewrite the path to ghc/hugs, and to the preprocessor+                         writeFile (lhs2texDir `joinFileName` snippet)+                                   ( -- replace "^%options ghc"        "%options ghc" .+                                     -- replace "^%options hugs"       "%options hugs" .+                                     -- TODO: replace or replaceEscaped+                                     replace "-pgmF \\.\\./lhs2TeX" ("-pgmF " ++ lhs2texBin ++ " -optF-Pdoc:") $ c )+                         let incToStyle ["verbatim"]   = "verb"+                             incToStyle ["stupid"]     = "math"+                             incToStyle ["tex"]        = "poly"+                             incToStyle ["polytt"]     = "poly"+                             incToStyle ["typewriter"] = "tt"+                             incToStyle [x]            = x+                             incToStyle []             = "poly"+                         callLhs2tex v lbi ["--" ++ incToStyle inc , "-Pdoc:", lhs2texDir `joinFileName` snippet]+                                           (lhs2texDocDir `joinFileName` s ++ ".tex")+                ) snippets+        callLhs2tex v lbi ["--poly" , "-Pdoc:", "doc" `joinFileName` "Guide2.lhs"]+                          (lhs2texDocDir `joinFileName` "Guide2.tex")+        copyFileVerbose v ("polytable" `joinFileName` "polytable.sty") (lhs2texDocDir `joinFileName` "polytable.sty")+        copyFileVerbose v ("polytable" `joinFileName` "lazylist.sty")  (lhs2texDocDir `joinFileName` "lazylist.sty")+        d <- getCurrentDirectory+        setCurrentDirectory lhs2texDocDir+        -- call pdflatex as long as necessary+        let loop = do rawSystemProgramConf v "pdflatex" (withPrograms lbi) ["Guide2.tex"]+                      x <- readFile "Guide2.log"+                      case matchRegex (mkRegexWithOpts "Warning.*Rerun" True True) x of+                        Just _  -> loop+                        Nothing -> return ()+        loop+        setCurrentDirectory d++lhs2texPostCopy a (CopyFlags { copyDest = cd, copyVerbose = v }) pd lbi =+    do  ebi <- getPersistLhs2texBuildConfig+        let dataPref = mkDataDir pd lbi cd+        createDirectoryIfMissing True dataPref+        let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+        -- lhs2TeX.{fmt,sty}+        mapM_ (\f -> copyFileVerbose v (lhs2texDir `joinFileName` f) (dataPref `joinFileName` f))+              ["lhs2TeX.fmt","lhs2TeX.sty"]+        -- lhs2TeX library+        fmts <- fmap (filter (".fmt" `isSuffixOf`)) (getDirectoryContents "Library")+        mapM_ (\f -> copyFileVerbose v ("Library" `joinFileName` f) (dataPref `joinFileName` f))+              fmts+        -- documentation difficult due to lack of docdir+        let lhs2texDocDir = lhs2texDir `joinFileName` "doc"+        let docDir = if isWindows+                       then dataPref `joinFileName` "Documentation"+                       else absolutePath pd lbi cd (datadir lbi `joinFileName` "doc" `joinFileName` datasubdir lbi)+        let manDir = if isWindows+                       then dataPref `joinFileName` "Documentation"+                       else absolutePath pd lbi cd (datadir lbi `joinFileName` "man" `joinFileName` "man1")+        createDirectoryIfMissing True docDir+        copyFileVerbose v (lhs2texDocDir `joinFileName` "Guide2.pdf") (docDir `joinFileName` "Guide2.pdf")+        when (not isWindows) $+          do createDirectoryIfMissing True manDir+             copyFileVerbose v ("lhs2TeX.1") (manDir `joinFileName` "lhs2TeX.1")+        -- polytable+        case (installPolyTable ebi) of+          Just texmf -> do  let texmfDir = absolutePath pd lbi cd texmf+                                ptDir = texmfDir `joinFileName` "tex" `joinFileName` "latex"+                                                 `joinFileName` "polytable"+                            createDirectoryIfMissing True ptDir+                            stys <- fmap (filter (".sty" `isSuffixOf`))+                                         (getDirectoryContents "polytable")+                            mapM_ (\f -> copyFileVerbose v ("polytable" `joinFileName` f)+                                                           (ptDir `joinFileName` f))+                                  stys+          Nothing    -> return ()+        return ExitSuccess++lhs2texPostInst a (InstallFlags { installUserFlags = u, installVerbose = v }) pd lbi =+    do  lhs2texPostCopy a (CopyFlags { copyDest = NoCopyDest, copyVerbose = v }) pd lbi+        lhs2texRegHook pd lbi Nothing (RegisterFlags { regUser = u, regInPlace = False, regWithHcPkg = Nothing, regGenScript = False, regVerbose = v })+        return ExitSuccess++lhs2texRegHook pd lbi _ (RegisterFlags { regVerbose = v }) =+    do  ebi <- getPersistLhs2texBuildConfig+        when (isJust . installPolyTable $ ebi) $+          do  rawSystemProgramConf v "mktexlsr" (withPrograms lbi) []+              return ()++lhs2texCleanHook pd lbi v pshs =+    do  cleanHook defaultUserHooks pd lbi v pshs+        try $ removeFile lhs2texBuildInfoFile+        mapM_ (try . removeFile) generatedFiles++matchRegexRepeatedly re str =+    case matchRegexAll re str of+      Just (_,_,r,[s]) -> s : matchRegexRepeatedly re r+      Nothing          -> []+++replace re t x = subRegex (mkRegexWithOpts re True True) x (escapeRegex t)+    where+    -- subRegex requires us to escape backslashes+    escapeRegex []        = []+    escapeRegex ('\\':xs) = '\\':'\\': escapeRegex xs+    escapeRegex (x:xs)    = x : escapeRegex xs+    +escapeChars :: String -> String+escapeChars t = foldr showLitChar [] t++showYesNo :: Bool -> String+showYesNo p | p          =  "yes"+            | otherwise  =  "no"++message :: String -> IO ()+message s = putStrLn $ "configure: " ++ s++stripNewlines :: String -> String+stripNewlines = filter (/='\n')++stripQuotes :: String -> String+stripQuotes ('\'':s@(_:_)) = init s+stripQuotes x              = x++callLhs2tex v lbi params outf =+    do  let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+        let lhs2texBin = lhs2texDir `joinFileName` lhs2tex+        let args    =  [ "-P" ++ lhs2texDir ++ ":" ]+                     ++ (if v > 4 then ["-v"] else [])+                     ++ params+        maybeExit $ runCommandRedirect v lhs2texBin args outf ++runCommandRedirect  ::  Int                       -- ^ verbosity+                    ->  String                    -- ^ the command+                    ->  [String]                  -- ^ args+                    ->  FilePath                  -- ^ output file+                    ->  IO ExitCode+runCommandRedirect v cmd args f =+    do  (ex,out,err) <- runCommand v cmd args+        writeFile f out+        hPutStr stderr (unlines . lines $ err)+        return ex++runCommandProgramConf  ::  Int                    -- ^ verbosity+                       ->  String                 -- ^ program name+                       ->  ProgramConfiguration   -- ^ lookup up the program here+                       ->  [String]               -- ^ args+                       ->  IO (ExitCode,String,String)+runCommandProgramConf v progName programConf extraArgs =+    do  (prog,args) <- getProgram progName programConf+        runCommand v prog (args ++ extraArgs)++getProgram :: String -> ProgramConfiguration -> IO (String, [String])+getProgram progName programConf = +             do  mProg <- lookupProgram progName programConf+                 case mProg of+                   Just (Program { programLocation = UserSpecified p,+                                   programArgs = args })  -> return (p,args)+                   Just (Program { programLocation = FoundOnSystem p,+                                   programArgs = args })  -> return (p,args)+                   _ -> (die (progName ++ " command not found"))++-- | Run a command in a specific environment and return the output and errors.+runCommandInEnv  ::  Int                   -- ^ verbosity+                 ->  String                -- ^ the command+                 ->  [String]              -- ^ args+                 ->  [(String,String)]     -- ^ the environment+                 ->  IO (ExitCode,String,String)+runCommandInEnv v cmd args env = +                 do  when (v > 0) $ putStrLn (cmd ++ concatMap (' ':) args)+                     let env' = if null env then Nothing else Just env+                     (cin,cout,cerr,pid) <- runInteractiveProcess cmd args Nothing env'+                     hClose cin+                     out <- hGetContents cout+                     err <- hGetContents cerr+                     stringSeq out (hClose cout)+                     stringSeq err (hClose cerr)+                     exit <- waitForProcess pid+                     return (exit,out,err)++-- | Run a command and return the output and errors.+runCommand  ::  Int                    -- ^ verbosity+            ->  String                 -- ^ the command+            ->  [String]               -- ^ args+            ->  IO (ExitCode,String,String)+runCommand v cmd args = runCommandInEnv v cmd args []++-- | Completely evaluates a string.+stringSeq :: String -> b -> b+stringSeq []      c  =  c+stringSeq (x:xs)  c  =  stringSeq xs c++getPersistLhs2texBuildConfig :: IO Lhs2texBuildInfo+getPersistLhs2texBuildConfig = do+  e <- doesFileExist lhs2texBuildInfoFile+  let dieMsg = "error reading " ++ lhs2texBuildInfoFile ++ "; run \"setup configure\" command?\n"+  when (not e) (die dieMsg)+  str <- readFile lhs2texBuildInfoFile+  case reads str of+    [(bi,_)] -> return bi+    _        -> die dieMsg++writePersistLhs2texBuildConfig :: Lhs2texBuildInfo -> IO ()+writePersistLhs2texBuildConfig lbi = do+  writeFile lhs2texBuildInfoFile (show lbi)+++-- HACKS because the Cabal API isn't sufficient:++-- Distribution.Compat.FilePath is supposed to be hidden in future+-- versions, so we need our own version of it:+joinFileName :: String -> String -> FilePath+joinFileName ""  fname = fname+joinFileName "." fname = fname+joinFileName dir ""    = dir+joinFileName dir fname+  | isPathSeparator (last dir) = dir++fname+  | otherwise                  = dir++pathSeparator:fname+  where + isPathSeparator :: Char -> Bool+ isPathSeparator | isWindows = ( `elem` "/\\" )+                 | otherwise = ( == '/' )+ pathSeparator   | isWindows = '\\'+                 | otherwise = '/'++-- It would be nice if there'd be a predefined way to detect this+isWindows = "mingw" `isPrefixOf` os || "win" `isPrefixOf` os 
+ StateT.lhs view
@@ -0,0 +1,70 @@+%-------------------------------=  --------------------------------------------+\subsection{State transformer}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module StateT                 (  module StateT  )+> where+>+> import Auxiliaries++%endif++|IO| mit internem Zustand und Fehlerbehandlung.++%if style == math+%format MkXIO (m) = m+%format unXIO (m) = m+%endif++> newtype XIO exc st a          =  MkXIO (st -> IO (Either exc a, st))++%if style /= math++> unXIO (MkXIO f)               =  f++%endif++\NB The state is preserved upon failure.++> instance Functor (XIO exc st) where+>     fmap f m                  =  m >>= \a -> return (f a)+>+> instance Monad (XIO exc st) where+>     return a                  =  MkXIO (\st -> return (Right a, st))+>     m >>= k                   =  MkXIO (\st -> do (r, st') <- unXIO m st+>                                                   case r of+>                                                     Left e  -> return (Left e, st')+>                                                     Right a -> unXIO (k a) st')++\NB We cannot replace |return (Left e, st')| by |return (r, st')| since+the type is not general enough then.++> fetch                         :: XIO exc st st+> fetch                         =  MkXIO (\st -> return (Right st, st))+>+> store                         :: st -> XIO exc st ()+> store st'                     =  MkXIO (\st -> return (Right (), st'))+>+> update                        :: (st -> st) -> XIO exc st ()+> update f                      =  do st <- fetch; store (f st)+>+> toIO                          :: XIO exc st a -> IO a+> toIO m                        =  do (a, _) <- unXIO m undefined; return (fromRight a)+>+> fromIO                        :: IO a -> XIO exc st a+> fromIO m                      =  MkXIO (\st -> do a <- m; return (Right a, st))+>+> raise                         :: exc -> XIO exc st a+> raise e                       =  MkXIO (\st -> return (Left e, st))+>+> try                           :: XIO exc st a -> XIO exc' st (Either exc a)+> try m                         =  MkXIO (\st -> do (r, st') <- unXIO m st; return (Right r, st'))+>+>+> handle                        :: XIO exc st a -> (exc -> XIO exc' st a) -> XIO exc' st a+> handle m h                    =  try m >>= either h return+>+> fromEither                    :: Either exc a -> XIO exc st a+> fromEither                    =  either raise return
+ TODO view
@@ -0,0 +1,22 @@+Features planned for 2.0+========================++* Finish the manual.++* Formatting directives parameterized by arity.++* Facilitate Windows use.++* Use ndm's FilePath library.++Features planned for post-2.0+=============================++* Configurable lexer.++Features planned for future versions of polytable+=================================================++* Private columns are not shared with save-/restorecolumns. (?)++* Support for rules.
+ TeXCommands.lhs view
@@ -0,0 +1,97 @@+%-------------------------------=  --------------------------------------------+\subsection{Pseudo-\TeX\ Commands}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module TeXCommands            (  module TeXCommands  )+> where+>+> import Data.Maybe+> import FiniteMap              (  FiniteMap  )+> import qualified FiniteMap as FM+> import Auxiliaries++%endif++> data Style                    =  Version | Help | SearchPath | Copying | Warranty | CodeOnly | NewCode | Verb | Typewriter | Poly | Math | Pre+>                                  deriving (Eq, Show, Enum, Bounded)++\Todo{Better name for |Class|.}++> data Class                    =  One                     Char         -- ordinary text+>                               |  Many                    String       -- ditto+>                               |  Inline                  String       -- @|..|@+>                               |  Command     Command     String       -- @\cmd{arg}@+>                               |  Environment Environment String       -- @\begin{cmd}..arg\end{cmd}@+>                               |  Directive   Directive   String       -- @%cmd arg@+>                               |  Error       Exc                      -- parsing error+>                                  deriving (Show)++> data Command                  =  Hs | Eval | Perform | Vrb Bool+>                                  deriving (Eq, Show)+>+> data Environment              =  Haskell | Code | Spec | Evaluate | Hide | Ignore | Verbatim Bool+>                                  deriving (Eq, Show)++\NB |Hs|, |Haskell|, |Hide|, and |Ignore| are obsolete.+ks, 16.08.2004: added EOF.++>+> data Directive                =  Format | Include | Let | File | Options+>                               |  Align | Separation | Latency | Begin | End | Subst+>                               |  If | Elif | Else | Endif | EOF+>                                  deriving (Eq, Show)++> data Numbered a               =  No !LineNo a+>                                  deriving (Show)+>++\NB The |Show| instances have been defined for debugging purposes, the+|Eq| instances are necessary for |decode|.++> conditional                   :: Directive -> Bool+> conditional If                =  True+> conditional Elif              =  True+> conditional Else              =  True+> conditional Endif             =  True+> conditional EOF               =  True+> conditional _                 =  False++Encoding and decoding of commands, environments, and directives.+\Todo{Better name for |Representation|.}++> class Representation a where+>     representation            :: [(String, a)]+> instance Representation Style where+>     representation            =  [ ("tt", Typewriter), ("math", Math), ("poly", Poly),+>                                    ("verb", Verb), ("code", CodeOnly), ("newcode",NewCode),+>                                    ("pre", Pre), ("version", Version),+>                                    ("copying", Copying), ("warranty", Warranty), ("help", Help), ("searchpath", SearchPath) ]+> instance Representation Command where+>     representation            =  [ ("hs", Hs), ("eval", Eval),+>                                    ("perform", Perform), ("verb*", Vrb True),+>                                    ("verb", Vrb False) ]+> instance Representation Environment where+>     representation            =  [ ("haskell", Haskell), ("code", Code),+>                                    ("spec", Spec), ("evaluate", Evaluate), ("hide", Hide),+>                                    ("ignore", Ignore), ("verbatim*", Verbatim True),+>                                    ("verbatim", Verbatim False) ]+> instance Representation Directive where+>     representation            =  [ ("format", Format), ("include", Include),+>                                    ("if", If), ("elif", Elif),+>                                    ("else", Else), ("endif", Endif),+>                                    ("let", Let), ("file", File),+>                                    ("options", Options), ("align", Align),+>                                    ("separation", Separation), ("latency", Latency),+>                                    ("{", Begin), ("}", End), ("subst", Subst),+>                                    ("EOF",EOF) ]+>+> encode                        :: (Representation a) => String -> Maybe a+> encode s                      =  FM.lookup s (FM.fromList representation)+>+> decode                        :: (Eq a, Representation a) => a -> String+> decode a                      =  fromJust (lookup a (inverse representation))++\NB We cannot use arrays for |decode|, because |Command| is neither an+enumerated nor a product type (|Vrb Bool|).
+ TeXParser.lhs view
@@ -0,0 +1,242 @@+%-------------------------------=  --------------------------------------------+\subsection{Pseudo-\TeX\ Parser}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module TeXParser              (  texparse  )+> where+> import Data.Char              (  isSpace, isAlpha  )+> import TeXCommands+> import Auxiliaries hiding     (  breaks  )++%endif++Care is taken that no character of the input is lost; this is necessary+for reporting the correct line number if an error occurs.++> texparse                      :: LineNo -> String -> [Numbered Class]+> texparse n                    =  number n . compress . classify0 ""++To be able to catch errors the maximum length of arguments is+restricted to |maxChar| for commands and to |maxLine| for+environments.++> maxChar, maxLine              :: Int+> maxChar                       =  1000+> maxLine                       =  80 * 500++A simple Pseudo-\TeX-Parser. \NB Pseudo-\TeX\ environments must not be+nested:+\[+     @\begin{code}...\begin{code}...\end{code}...\end{code}@+\]+is not parsed properly.++|classify0| is only used at the start of a file or line; it recognizes+bird (and inverse bird) tracks.++> classify0                     :: String -> String -> [Class]+> classify0 _ []                =  []+> classify0 n ('>' : s)         =  Environment Code (n ++ ' ' : t) : classify0 "" u+>     where (t, u)              =  unbird '>' s+> classify0 n ('<' : s)         =  Environment Spec (n ++ ' ' : t) : classify0 "" u+>     where (t, u)              =  unbird '<' s+> classify0 n s                 =  Many n : classify s++\NB The preceding newline (if any) is put into the code section to be+able to suppress blank lines in the \LaTeX\ text.++> classify                      :: String -> [Class]+> classify []                   =  []+> classify ('\n' : s)           =  classify0 "\n" s++Commands disguised as comments (AKA pseudo-comments).+ks, 19.08.2004: changed |classify v| to |classify0 v| calls, to recognize+(incorrect-Haskell) bird tracks directly after a directive.++> classify ('%' : s)            =  case encode t of+>         Nothing               -> Many ('%' : t ++ arg)  :  classify0 "" v+>         Just cmd              -> Directive cmd arg      :  classify0 "" v+>     where (t, u)              =  break isSpace s+>           (arg, v)            =  breakAfter (== '\n') u++\NB Text starting with @%@ is ignored; in most cases this is what+you want (exception @\%@).++Environments.++> classify str@('\\' : s)       =  case span isIdChar s of+>     ("begin", '{' : t)        -> case span isIdChar t of+>         (env, '}' : u)        -> case encode env of+>             Nothing           -> cont+>             Just cmd+>                 | pred v      -> Environment cmd (arg ++ w) : classify x+>                 | otherwise   -> notFound end str :  cont+>                 where+>                 end           =  "\\end{" ++ env ++ "}"+>                 pred          =  isPrefix end+>                 (arg, v)      =  breaks maxLine pred u+>                 (w, x)        =  blank (drop (length end) v)+>         _                     -> cont++Inline verbatim commands are treated specially; otherwise @\verb|a|@+would be mistaken as inline code. Furthermore: then we are able to+write @\verb|\begin{code}|@.++>     ("verb*", c : t)          -> verbatim True c t+>     ("verb",  c : t)          -> verbatim False  c t++Commands.++>     (cmd, '{' : t)            -> case encode cmd of+>         Nothing               -> cont+>         Just cmd              -> case nested maxChar 0 t of+>             (a, '}' : u)      -> Command cmd a : classify u+>             _                 -> notFound "matching `}'" str : cont+>     _                         -> cont+>     where+>     cont                      =  One '\\' : classify s+>     verbatim b c t            =  case verb maxChar c t of+>         (u, c' : v) | c == c' -> Command (Vrb b) u : classify v+>         _                     -> notFound ("matching `" ++ [c] ++ "'") str : cont++Inline code.++> classify ('|' : '|' : s)      =  One '|' : classify s+> classify str@('|' : s)        =  case inline maxChar s of+>     (arg, '|' : t)            -> Inline arg : classify t+>     _                         -> notFound "matching `|'" str : One '|' : classify s++Short verb.++> classify ('@' : '@' : s)      =  One '@' : classify s+> classify str@('@' : s)        =  case shortverb maxChar s of+>     (arg, '@' : t)            -> Command (Vrb False) arg : classify t+>     _                         -> notFound "matching `@'" str : One '@' : classify s++Everything else.++> classify (c : s)              =  One c : classify s++> notFound                      :: String -> String -> Class+> notFound what s               =  Error (what ++ " not found", s)++> isIdChar                      :: Char -> Bool+> isIdChar c                    =  isAlpha c || c == '*'++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Parsing of arguments}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++The parser satisfy+%+\begin{eqnarray*}+    |parse M.s = (M.l, M.r)|      & |==>| & |M.s = M.l ++ M.r|+\end{eqnarray*}+%+The function |nested n 0| recognizes arguments enclosed in matching+curly braces.++> nested                        :: Int -> Int -> String -> (String, String)+> nested n depth s              =  nest n s+>     where+>     nest 0 s                  =  ([], s)+>     nest n []                 =  ([], [])+>     nest n  ('}' : s)+>         | depth == 0          =  ([], '}' : s)+>         | otherwise           =  '}' <| nested (n - 1) (depth - 1) s+>     nest n ('{' : s)          =  '{' <| nested (n - 1) (depth + 1) s+>     nest n ('\\' : c : s)     =  '\\' <| c <| nest (n - 2) s+>     nest n (c : s)            =  c <| nest (n - 1) s++The function |verb n c| recognizes arguments enclosed in |c|.++> verb                          :: Int -> Char -> String -> (String, String)+> verb 0 c s                    =  ([], s)+> verb n c []                   =  ([], [])+> verb n c (c' : s)+>     | c == c'                 =  ([], c' : s) +>     | otherwise               =  c' <| verb (n - 1) c s++The function |inline n| recognizes arguments enclosed in vertical bars+(and converts double bars into single bars; therefore it is \emph{not}+equivalent to |verb n '||'|).++> inline                        :: Int -> String -> (String, String)+> inline 0 s                    =  ([], s)+> inline n []                   =  ([], [])+> inline n ('|' : '|' : s)      =  '|' <| inline (n - 2) s+> inline n ('|' : s)            =  ([], '|' : s) +> inline n (c : s)              =  c <| inline (n - 1) s+>+> shortverb                     :: Int -> String -> (String, String)+> shortverb 0 s                 =  ([], s)+> shortverb n []                =  ([], [])+> shortverb n ('@' : '@' : s)   =  '@' <| shortverb (n - 2) s+> shortverb n ('@' : s)         =  ([], '@' : s) +> shortverb n (c : s)           =  c <| shortverb (n - 1) s++The function |unbird| recognizes code sections marked by bird tracks;+|blank| skips the next line if it is blank.++> unbird                        :: Char -> String -> (String, String)+> unbird c []                   =  ([], [])+> unbird c ('\n' : c' : s)+>     | c == c'                 =  '\n' <| ' ' <| unbird c s+> unbird c ('\n' : s)           =  '\n' <| blank s+> unbird c (c' : s)             =  c' <| unbird c s+>+> blank                         :: String -> (String, String)+> blank s | all isSpace t       =  (t, u)+>         | otherwise           =  ("", s)+>         where (t, u)          =  breakAfter (== '\n') s++|breaks n pred as| returns |(x, y)| such that |as = x ++ y|, |pred y|+holds and |x| is as small as possible (but at most of length |n|).++> breaks                        :: Int -> ([a] -> Bool) -> [a] -> ([a], [a])+> breaks n pred []              =  ([], [])+> breaks n pred as@(a : as')+>     | n == 0 || pred as       =  ([], as)+>     | otherwise               =  a <| breaks (n - 1) pred as'++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Post processing}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Collaps adjacent |One|'s into a |Many|.++> compress                      =  foldr (<|) []+>     where+>     One '\n' <| ts            =  Many "\n" : ts+>     Many s@('\n' : _) <| ts   =  Many s : ts+>     One c <| (Many s : ts)    =  Many (c : s) : ts+>     One c <| ts               =  Many [c] : ts+>     Many s <| (Many s' : ts)  =  Many (s ++ s') : ts+>     t <| ts                   =  t : ts++\NB The first two equations make |compress| incrementel (?); otherwise+\[+    |do s <- readFile "Examples/InfI.lhs"; mapM_ print (compress (map One s))|+\]+is silent until the complete input has been digested.++Adding line numbers.++> number                        :: LineNo -> [Class] -> [Numbered Class]+> number n []                   =  []+> number n (t : ts)             =  No n t : number (n + i) ts+>     where i                   =  case t of+>             One c             -> impossible "number"+>             Many s            -> newlines s+>             Inline s          -> newlines s+>             Command _ s       -> newlines s+>             Environment _ s   -> newlines s+>             Directive _ s     -> newlines s+>             Error _           -> 0++Number of newline characters in a string.++> newlines                      :: String -> Int+> newlines s                    =  length [ c | c <- s, c == '\n' ]
+ Testsuite/Makefile view
@@ -0,0 +1,244 @@++include config.mk++main            := Main.lhs+psources        := $(main) TeXCommands.lhs TeXParser.lhs \+		   Typewriter.lhs Math.lhs MathPoly.lhs \+                   MathCommon.lhs NewCode.lhs \+		   Directives.lhs HsLexer.lhs FileNameUtils.lhs \+		   Parser.lhs FiniteMap.lhs Auxiliaries.lhs \+		   StateT.lhs Document.lhs Verbatim.lhs Value.lhs+sources         := $(psources) Version.lhs+snipssrc        := sorts.snip id.snip cata.snip spec.snip+snips	        := sorts.tt sorts.math id.math cata.math spec.math+objects         := $(sources:.lhs=.o)+sections       	:= $(sources:.lhs=.tex)++MKINSTDIR       := ./mkinstalldirs++###+### lhs dependencies (from %include lines)+###++ifdef SORT+ifdef UNIQ++MKLHSDEPEND = $(GREP) "^%include " $< \+               | $(SED) -e 's,^%include ,$*.tex : ,' \+               | $(SORT) | $(UNIQ) > $*.ld++MKFMTDEPEND = $(GREP) "^%include " $< \+               | $(SED) -e 's,^%include ,$*.fmt : ,' \+               | $(SORT) | $(UNIQ) > $*.ld++endif+endif++###+### dependency postprocessing+###++DEPPOSTPROC = $(SED) -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \+	         -e '/^$$/ d' -e 's/$$/ :/'++###+### default targets+###++.PHONY : default xdvi gv print install backup clean all depend bin doc srcdist++all : default++default : bin doc+bin : lhs2TeX lhs2TeX.fmt lhs2TeX.sty++-include $(sources:%.lhs=%.d)++# I don't understand this ... (ks)+#+# %.hi : %.o+# 	@if [ ! -f $@ ] ; then \+#	echo $(RM) $< ; \+#	$(RM) $< ; \+#	set +e ; \+#	echo $(MAKE) $(notdir $<) ; \+#	$(MAKE) $(notdir $<) ; \+#	if [ $$? -ne 0 ] ; then \+#	exit 1; \+#	fi ; \+#	fi++ifdef MKLHSDEPEND++%.ld : %.lhs+	$(MKLHSDEPEND); \+	$(CP) $*.ld $*.ldd; \+	$(DEPPOSTPROC) < $*.ldd >> $*.ld; \+	$(RM) -f $*.ldd++%.ld : %.fmt+	$(MKFMTDEPEND); \+	$(CP) $*.ld $*.ldd; \+	$(DEPPOSTPROC) < $*.ldd >> $*.ld; \+	$(RM) -f $*.ldd++-include $(sources:%.lhs=%.ld)++endif++%.tex : %.lhs lhs2TeX Lhs2TeX.fmt lhs2TeX.fmt+#	lhs2TeX -verb -iLhs2TeX.fmt $< > $@+	./lhs2TeX --math --align 33 -iLhs2TeX.fmt $< > $@++%.tt : %.snip lhs2TeX lhs2TeX.fmt+	./lhs2TeX --tt -lmeta=True -ilhs2TeX.fmt $< > $@++%.math : %.snip lhs2TeX lhs2TeX.fmt+	./lhs2TeX --math --align 33 -lmeta=True -ilhs2TeX.fmt $< > $@++%.tex : %.lit lhs2TeX+	./lhs2TeX --verb -ilhs2TeX.fmt $< > $@+++lhs2TeX.sty: lhs2TeX.sty.lit lhs2TeX+	./lhs2TeX --code lhs2TeX.sty.lit > lhs2TeX.sty+lhs2TeX.fmt: lhs2TeX.fmt.lit lhs2TeX+	./lhs2TeX --code lhs2TeX.fmt.lit > lhs2TeX.fmt++lhs2TeX : $(sources)+	$(GHC) $(GHCFLAGS) --make -o lhs2TeX $(main)++doc : bin+	cd doc; $(MAKE)+#	cd Guide; $(MAKE) Guide.pdf++INSTALL : lhs2TeX INSTALL0 INSTALL1+	cp INSTALL0 $@+	./lhs2TeX --searchpath >> $@+	cat INSTALL1 >> $@++depend:+	$(GHC) -M -optdep-f -optdeplhs2TeX.d $(GHCFLAGS) $(sources)+	$(RM) -f lhs2TeX.d.bak++lhs2TeX-includes : lhs2TeX.sty $(sections) $(snips) lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex++Lhs2TeX.dvi : lhs2TeX-includes+Lhs2TeX.pdf : lhs2TeX-includes++xdvi : Lhs2TeX.dvi+	$(XDVI) -s 3 Lhs2TeX.dvi &++gv : Lhs2TeX.ps+	$(GV) Lhs2TeX.ps &++print : Lhs2TeX.dvi+	$(DVIPS) -D600 -f Lhs2TeX.dvi | lpr -Pa -Zl++install : bin doc+	$(MKINSTDIR) $(DESTDIR)$(bindir)+	$(INSTALL) -m 755 lhs2TeX $(DESTDIR)$(bindir)+	$(MKINSTDIR) $(DESTDIR)$(stydir)+	$(INSTALL) -m 644 lhs2TeX.sty lhs2TeX.fmt $(DESTDIR)$(stydir)+	$(INSTALL) -m 644 Library/*.fmt $(DESTDIR)$(stydir)+	$(MKINSTDIR) $(DESTDIR)$(docdir)+	$(INSTALL) -m 644 doc/Guide2.pdf $(DESTDIR)$(docdir)+	$(MKINSTDIR) $(DESTDIR)$(mandir)/man1+	$(INSTALL) -m 644 lhs2TeX.1 $(DESTDIR)$(mandir)/man1+ifeq ($(INSTALL_POLYTABLE),yes)+# install polytable package+	$(MKINSTDIR) $(DESTDIR)$(polydir)+	$(INSTALL) -m 644 polytable/*.sty $(DESTDIR)$(polydir)+endif+	# $(MKINSTDIR) $(DESTDIR)$(texdir)+	# $(INSTALL) -m 644 Library/*.sty $(DESTDIR)$(texdir)+ifndef DESTDIR+	$(MKTEXLSR)+else+	echo "Please update the TeX filename database."+endif++srcdist : INSTALL doc+	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi+	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/doc+	$(MKINSTDIR) $(DISTDIR)/polytable+	$(MKINSTDIR) $(DISTDIR)/Testsuite+	$(MKINSTDIR) $(DISTDIR)/Examples+	$(MKINSTDIR) $(DISTDIR)/Library+	$(INSTALL) -m 644 $(psources) Version.lhs.in $(snipssrc) $(DISTDIR)+	$(INSTALL) -m 644 Setup.hs lhs2tex.cabal $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)+	$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)+	$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE RELEASE $(DISTDIR)+	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \+		> $(DISTDIR)/INSTALL+	chmod 644 $(DISTDIR)/INSTALL+	cd doc; $(MAKE) srcdist+	$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable+	$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Makefile $(DISTDIR)/Testsuite+	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples+	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples+	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library+	tar cvjf $(DISTDIR).tar.bz2 $(DISTDIR)+	chmod 644 $(DISTDIR).tar.bz2++ifdef DISTTYPE++bindist: lhs2TeX lhs2TeX.fmt lhs2TeX.sty doc+	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi+	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/doc+	$(MKINSTDIR) $(DISTDIR)/polytable+	$(MKINSTDIR) $(DISTDIR)/Testsuite+	$(MKINSTDIR) $(DISTDIR)/Examples+	$(MKINSTDIR) $(DISTDIR)/Library+	$(INSTALL) -m 755 lhs2TeX $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt lhs2TeX.sty $(DISTDIR)+	$(INSTALL) -m 644 $(psources) Version.lhs.in $(snipssrc) $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.fmt.lit lhs2TeX.sty.lit $(DISTDIR)+	$(INSTALL) -m 644 Makefile common.mk config.mk.in $(DISTDIR)+	$(INSTALL) -m 644 lhs2TeX.1.in $(DISTDIR)+	$(INSTALL) -m 755 configure mkinstalldirs install-sh $(DISTDIR)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE RELEASE $(DISTDIR)+	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \+		> $(DISTDIR)/INSTALL+	chmod 644 $(DISTDIR)/INSTALL+	cd doc; $(MAKE) srcdist+	$(INSTALL) -m 644 polytable/*.{sty,pdf} $(DISTDIR)/polytable+	$(INSTALL) -m 644 Testsuite/*.{lhs,snip} Makefile $(DISTDIR)/Testsuite+	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples+	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples+	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library+	tar cvjf $(DISTDIR)-$(DISTTYPE).tar.bz2 $(DISTDIR)+	chmod 644 $(DISTDIR)-$(DISTTYPE).tar.bz2++else++bindist:+	@echo "You must define DISTTYPE."++endif++backup:+	cd ..; \+	$(RM) -f Literate.tar Literate.tar.gz; \+	tar -cf Literate.tar Literate; \+	gzip Literate.tar; \+	chmod a+r Literate.tar.gz++clean :+#	clean+	$(RM) -f lhs2TeX $(sections) $(snips) $(objects) *.hi *.dvi *.ps+	-$(RM) -f *.d *.dd *.ld *.ldd+	$(RM) -f lhs2TeX.sty lhs2TeX.fmt+	$(RM) -f Lhs2TeX.tex lhs2TeX.sty.tex lhs2TeX.fmt.tex Makefile.tex +	cd doc; $(MAKE) clean++# all:+# 	$(MAKE) install+# 	$(MAKE) Lhs2TeX.dvi++include common.mk
+ Testsuite/Test.lhs view
@@ -0,0 +1,164 @@+\documentclass[fleqn]{article}++\usepackage[german]{babel}+\usepackage{moreverb}+\usepackage{boxedminipage}+\parindent0cm++\newcommand{\Show}[1]{\listinginput{1}{#1.snip}\input{#1.tex}}++%-------------------------------=  --------------------------------------------++%include ../lhs2TeX.fmt++%-------------------------------=  --------------------------------------------++\begin{document}++%-------------------------------=  --------------------------------------------+\section{String gaps}+%-------------------------------=  --------------------------------------------++\Show{gap}++%-------------------------------=  --------------------------------------------+\section{Identifiers}+%-------------------------------=  --------------------------------------------++\Show{idents}++%-------------------------------=  --------------------------------------------+\section{Operators}+%-------------------------------=  --------------------------------------------++\Show{operators}++%-------------------------------=  --------------------------------------------+\section{Special symbols}+%-------------------------------=  --------------------------------------------++\Show{special}++%-------------------------------=  --------------------------------------------+\section{Spacing}+%-------------------------------=  --------------------------------------------++\Show{spacing}+\Show{braces}++%-------------------------------=  --------------------------------------------+\section{Indentation}+%-------------------------------=  --------------------------------------------++\Show{indentation}+%+\NB Die senkrechten Striche sind im ersten Beispiel etwas einger"uckt,+da \verb|\mid| als Operator gesetzt wird. Schlie"st man die linke Seite+in \verb|{..}| ein, dann wird |weird| nicht richtig gesetzt. Die rechte+Seite \emph{wird} in \verb|{..}| eingeschlossen, damit |list| und+|main| richtig gesetzt werden (auf diese Weise verliert \verb|\mid|+seinen Status als Operator).++%-------------------------------=  --------------------------------------------+\section{Format directives}+%-------------------------------=  --------------------------------------------++\Show{format}+\Show{parens}++%-------------------------------=  --------------------------------------------+\section{Errors}+%-------------------------------=  --------------------------------------------++\Show{errors}++%-------------------------------=  --------------------------------------------+\section{Meta-Haskell}+%-------------------------------=  --------------------------------------------++Erfordert \verb|-l'meta = True'| Kommandozeilenoption (wichtig: \emph{vor}+\verb@-i lhs2TeX.fmt@ angeben).+%+\Show{meta}++%-------------------------------=  --------------------------------------------+\section{Comments}+%-------------------------------=  --------------------------------------------++\Show{comments}++%-------------------------------=  --------------------------------------------+\section{Verbatim}+%-------------------------------=  --------------------------------------------++\verb|khadrkh| und \verb*|kjhsfd  kjghsdf|.+%+\begin{verbatim}+bass  sdakh asd asd+\end{verbatim}+%+\begin{verbatim*}+bass  sdakh asd asd+\end{verbatim*}++%-------------------------------=  --------------------------------------------+\section{Active commands}+%-------------------------------=  --------------------------------------------++|product [1..20]| yields \eval{product [1..20]}.+%if False++> default (Integer)++> group n			=  map (take n)+>				.  takeWhile (not . null)+>				.  iterate (drop n)+> rows				=  concat+>				.  intersperse " \\\\\n"+>				.  map (\(n, s) -> show n ++ " & " ++ s)+>				.  zip [1 ..]+>				.  group 60+> intersperse s []		=  []+> intersperse s [a]		=  [a]+> intersperse s (a1 : a2 : as)	=  a1 : s : intersperse s (a2 : as)+> out n				=  putStr (rows (show n))++%endif+|product [1..200]| yields+\[+\begin{array}{rl}+    \perform{out (product [1..200])}+\end{array}+\]++> twice f a			=  f (f a)++\eval{:type twice} und \eval{:type twice twice} haben den gleichen+Typ.++%-------------------------------=  --------------------------------------------+\section{Active commands with @ghci@}+%-------------------------------=  --------------------------------------------++%options ghci -fglasgow-exts -fno-monomorphism-restriction+|product [1..20]| yields \eval{product [1..20]}.+%if False++> main = undefined++%endif+|product [1..200]| yields+\[+\begin{array}{rl}+    \perform{out (product [1..200])}+\end{array}+\]++< twice f a			=  f (f a)++%format forall = "\forall "+%format .      = "."+\eval{:type twice} und \eval{:type twice twice} haben den gleichen+Typ.++\end{document}
+ Testsuite/Try.lhs view
@@ -0,0 +1,4 @@+> go	=  concat [ show n ++ ": " ++ [toEnum n] ++ ", \\symbol{" ++ show n ++ "}\\\\\n"+>          | n <- [32 .. 127] ]++> go' = unlines [ concat [ [toEnum i, ' '] | i <- [32 + 24 * n .. 55 + 24 * n] ] | n <- [0 .. 3] ]
+ Testsuite/braces.snip view
@@ -0,0 +1,6 @@+Records: |fun (State{dict = d, no = n})|, |fun (State{dict = d, no = n})|.++> main				=  do { putStr "hello";+>				        putStr "world";+>				        exit+>				      }
+ Testsuite/comments.snip view
@@ -0,0 +1,4 @@+Inline comments: |fun -- ny| und |first {- second -} third|.++> a `elem` []			=  False	-- vordefiniert+> a `elem` (b : bs)		=  a == b {- lazy -} || a `elem` bs
+ Testsuite/errors.snip view
@@ -0,0 +1,2 @@+% format f (a = a+% format f a = b
+ Testsuite/format.snip view
@@ -0,0 +1,15 @@+%format f a b = "\varphi\;" a b++> bla = yuks (f a	-- works+>               b)+> bla = yuks (f a	-- does not work+>          b)++\NB Es ist wichtig bei der Ersetzung, da"s nur das erste Token des+Ersetzungstextes die Position erbt; sonst wird |b| nicht richtig+positioniert.++%format a1+%format a2++> ordered (a1 : a2 : as)	=  a1 <= a2 && ordered (a2 : as)
+ Testsuite/gap.snip view
@@ -0,0 +1,3 @@+> msg                           =  "Hello world\n\+>                                  \how are you doing?\n\+>                                  \Cheers."
+ Testsuite/idents.snip view
@@ -0,0 +1,7 @@+Varianten: |fun what now|, |Prelude.take 10 x|.+Mit Unterstrich: |mapM_| und |remove_leading_line|.+%format Verbatim = "\mathrm{Verb}"+%format Verbatim.a = "\mathit{a}"+|Verbatim.a + Math.b + Verbatim.b|.+%format empty = "\emptyset "+|Bag.empty| oder |Set.empty|
+ Testsuite/indentation.snip view
@@ -0,0 +1,12 @@+> faculty  n+>     | n == 0			=  1+>     | otherwise		=  n * faculty n'+>     where n'			=  n - 1+>           unused		=  n'+> weird a b+>     where (c, d) | cond	=  (a, b)+>                  | otherwise	=  (b, a)+> list				=  [ i * i+>				   | i <- [0 .. 99 ] ]+> main				=  sequence [ print i+>				            | i <- [0 .. 99] ]
+ Testsuite/meta.snip view
@@ -0,0 +1,7 @@+\begin{equation}+|(M.forall a, x) ordered x ==> ordered (insert a x)|,+\end{equation}+\begin{equation}+|(M.forall M.x, M.y) ordered M.x /\ ordered M.y ==> ordered (merge M.x M.y)|.+\end{equation}+
+ Testsuite/operators.snip view
@@ -0,0 +1,8 @@+Variablen: |a !! 3|, |a + b|, |a Prelude.+ b|, |a `div` b|, |a `Prelude.div` b|.+Konstruktoren: |l :^: r|, |l Tree.:^: r|, |l `Br` r|, |l `Tree.Br` r|.+Selbstdefinierte: |f @@ g|, |f .> g|, |x `isPrefixOf` y|.+%format @@ = "\mathbin{\varocircle}"+%format .> = "\mathbin{\fatsemi}"+Noch einmal: |f @@ g|, |f .> g|, |a `elem` set| und |a `notElem` set|.+Beachte: |a `div` b| versus |a ` div ` b|.+Sections: |(`div` 2)| und |(+ 5)|.
+ Testsuite/parens.snip view
@@ -0,0 +1,31 @@+%format (abs (a))   = "|" a "|"+%format power a (b) = a "^{" b "}"+%format (sqrt (a))  = "\sqrt{" a "}"+%format (pair (a) (b)) = "\langle" a "," b "\rangle"+|power (abs (a + b)) (1/2)|, |f (abs a)|, |p (_, _) = 1|,+|let a' = abs a in sqrt (a' + a)|, |fun (gun a b^27) c ++ b^^(-8)|,+|abs (a, b)|, |abs (+ a * b)|, |abs ()|, |abs (a * b +)|,+|f (pair (a * b) (a / b))|, |map sqrt x|.++Newtype.+%format (MkSet (a)) = a++> newtype Set a 		=  MkSet [a]+> insert			:: a -> Set a -> Set a+> insert a (MkSet [])		=  MkSet [a]+> insert a (MkSet ((b : x)))+>     | a <= b			=  MkSet (a : b : x) +>     | otherwise		=  MkSet (b : insert a x)++%format (MkId (a)) = a++> newtype Id a          	=  MkId a+>+> instance Monad Id where+>     return a         		=  MkId a {-""-}+>     MkId a >>= f        	=  f a++Es werden niemals zwei Klammerpaare entfernt |((e))|.+%format f (a) = "\Varid{f}\;" a+%format (g a) = "\Varid{g}\;" a+Ja: |f (g a)| und nein: |f ((g a))|.
+ Testsuite/spacing.snip view
@@ -0,0 +1,7 @@+> infixr @@ 2+> infixr .> 3++Schl"usselwo"rter: |let x = 1 in x * x|, |fun (let x = 1 in x * x)|,+|let (a, b) = (b, a) in a * b|, |[let a=1 in a, let b=2 in b]|,+|let {a = 1; b = 2} in a * b|, |do {let a = 1; return (a * a)}|.+Listen: |[1,2,3] ++ [a]|.
+ Testsuite/special.snip view
@@ -0,0 +1,10 @@+< "  ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7"+< "8 9 : ; < = > ? @ A B C D E F G H I J K L M N O"+< "P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g"+< "h i j k l m n o p q r s t u v w x y z { | } ~"++|[1 .. 99]|, |fac :: Int -> Int|, |fac n = n * fac (n -1)|,+|\n -> n + 1|, |[ i * i || i <- [0..99] ]|, |x@(~(a : as))|.++< m >> n			= m >>= \_ -> n+
+ Typewriter.lhs view
@@ -0,0 +1,95 @@+%-------------------------------=  --------------------------------------------+\subsection{Typewriter formatter}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Typewriter             (  module Typewriter  )+> where+>+> import Verbatim ( trim, expand )+> import Document+> import Directives+> import HsLexer+> import qualified FiniteMap as FM+> import Auxiliaries++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline, display               :: Formats -> String -> Either Exc Doc+> inline dict                   =  tokenize+>                               @> lift (latexs sub'thin sub'thin dict)+>                               @> lift sub'inline++> display dict                  =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize+>                               @> lift (latexs sub'space sub'nl dict)+>                               @> lift sub'code++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{\LaTeX\ encoding}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> latexs                        :: Doc -> Doc -> Formats -> [Token] -> Doc+> latexs sp nl dict             =  catenate . map (latex sp nl dict)+>+> latex                         :: Doc -> Doc -> Formats -> Token -> Doc+> latex sp nl dict              =  tex Empty+>     where+>     tex _ (Space s)           =  sub'spaces (convert s)+>     tex q (Conid s)           =  replace q s (sub'conid (q <> convert s))+>     tex _ (Varid "")          =  sub'dummy    -- HACK+>     tex q (Varid s)           =  replace q s (sub'varid (q <> convert s))+>     tex q (Consym s)          =  replace q s (sub'consym (q <> convert s))+>     tex q (Varsym s)          =  replace q s (sub'varsym (q <> convert s))+>     tex _ (Numeral s)         =  replace Empty s (sub'numeral (convert s)) -- NEU+>     tex _ (Char s)            =  sub'char (catenate (map conv' (init $ tail s))) -- NEW: remove quotes+>     tex _ (String s)          =  sub'string (catenate (map conv' (init $ tail s))) -- NEW: remove quotes+>     tex _ (Special c)         =  sub'special (replace Empty [c] (conv c))+>     tex _ (Comment s)         =  sub'comment (Embedded s)+>     tex _ (Nested s)          =  sub'nested (Embedded s)+>     tex _ (Pragma s)          =  sub'pragma (Embedded s)+>     tex _ (Keyword s)         =  replace Empty s (sub'keyword (convert s))+>     tex _ (TeX d)             =  d+>     tex _ t@(Qual ms t')      =  replace Empty (string t) (tex (catenate (map (\m -> tex Empty (Conid m) <> Text ".") ms)) t')+>     tex _ t@(Op t')           =  replace Empty (string t) (cmd (conv '`' <> tex Empty t' <> conv '`'))+>         where cmd | isConid t'=  sub'consym+>                   | otherwise =  sub'varsym+>+>     replace q s def           =  case FM.lookup s dict of+>         Just (_, _, [], ts)   -> q <> catenate (map (tex Empty) ts)+>         _                     -> def++\NB the directives @%format a = b@ and @%format b = a@ cause a loop.+ +\NB Only nullary macros are applied.++Conversion of strings and characters.++>     convert                   :: String -> Doc+>     convert s                 =  catenate (map conv s)+>     conv                      :: Char -> Doc+>     conv ' '                  =  sp+>     conv '\n'                 =  nl+>     conv c+>       | c `elem` "#$%&"       =  Text ("\\" ++ [c])+>       | c `elem` "\"\\^_{}~"  =  Text (char c)+>       | otherwise             =  Text [c]+>+>     conv' ' '                 =  Text "~" -- NEW: instead of |Text (char ' ')| -- for character and string literals+>     conv' c                   =  conv c++\NB The character @"@ is not copied verbatim, to be able to use+@german.sty@ (@"@ is made active).++\NB The coding of characters is not independent of the \TeX\ font used,+eg @\/@ appears different in italics and typewriter (@\@ is+\texttt{\char'134} in typewriter, but \textit{\char'134} in italics).++> char                          :: Char -> String+> char c                        =  "\\char" ++ show (fromEnum c) ++ " "
+ Value.lhs view
@@ -0,0 +1,86 @@+%-------------------------------=  --------------------------------------------+\subsection{Value type}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Value (module Value)+> where++%endif++> data Value                    =  Undef+>                               |  Str  String+>                               |  Bool Bool+>                               |  Int  Int++Dynamic conversion routines.++> str                           :: Value -> String  +> str Undef                     =  ""+> str (Str s)                   =  s+> str (Bool b)                  =  if b then "True" else ""+> str (Int i)                   =  show i+>+> bool                          :: Value -> Bool  +> bool Undef                    =  False+> bool (Str s)                  =  not (null s)+> bool (Bool b)                 =  b+> bool (Int i)                  =  i /= 0+>+> int                           :: Value -> Int  +> int Undef                     =  0+> int (Str s)                   =  case reads s of+>     [(i, [])]                 -> i+>     _                         -> 0+> int (Bool b)                  =  if b then 1 else 0+> int (Int i)                   =  i++Lifting unsary and binary operations to |Value|.++> type Unary a                  =  a -> a+>+> onStr1                        :: Unary String -> Unary Value+> onStr1 f                      =  Str . f . str+>+> onBool1                       :: Unary Bool -> Unary Value+> onBool1 f                     =  Bool . f . bool+>+> onInt1                        :: Unary Int -> Unary Value+> onInt1 f                      =  Int . f . int++%{+%format s1+%format s2+%format b1+%format b2+%format i1+%format i2++> type Binary a                 =  a -> a -> a+>+> onStr2                        :: Binary String -> Binary Value+> onStr2 (++) v1 v2             =  Str (str v1 ++ str v2)+>+> onBool2                       :: Binary Bool -> Binary Value+> onBool2 (||) v1 v2            =  Bool (bool v1 || bool v2)+>+> onInt2                        :: Binary Int -> Binary Value+> onInt2 (+) v1 v2              =  Int (int v1 + int v2)++%align 41+{\setlength{\lwidth}{5.5cm}++> onMatching f g h Undef     (Str s2)   =  Bool (f (str Undef) s2)+> onMatching f g h (Str s1)  Undef      =  Bool (f s1 (str Undef))+> onMatching f g h (Str s1)  (Str s2)   =  Bool (f s1 s2)+> onMatching f g h Undef     (Bool b2)  =  Bool (g (bool Undef) b2)+> onMatching f g h (Bool b1) Undef      =  Bool (g b1 (bool Undef))+> onMatching f g h (Bool b1) (Bool b2)  =  Bool (g b1 b2)+> onMatching f g h Undef     (Int i2)   =  Bool (h (int Undef) i2)+> onMatching f g h (Int i1)  Undef      =  Bool (h i1 (int Undef))+> onMatching f g h (Int i1)  (Int i2)   =  Bool (h i1 i2)+> onMatching _ _ _ _ _                  =  Bool False++}+%}
+ Verbatim.lhs view
@@ -0,0 +1,81 @@+%-------------------------------=  --------------------------------------------+\subsection{Verbatim formatter}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Verbatim               (  module Verbatim  )+> where+>+> import Data.Char+>+> import Document+> import Auxiliaries++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++The Boolean flag indicates whether a space should be typeset as \verb*| | (|True|) or not.++> inline                        :: Bool -> String -> Doc+> inline b                      =  latexs b .> sub'verb+>+> display                       :: Int -> Bool -> String -> Doc+> display width b               =  trim+>                               .> expand 0+>                               .> lines+>                               .> map (group width)+>                               .> map (map (latexs b))+>                               .> map splice+>                               .> intersperse sub'verbnl+>                               .> catenate+>                               .> sub'verbatim+>+> splice                        :: [Doc] -> Doc+> splice ds                     =  Text "~" <> catenate (intersperse nl ds)+>     where nl                  =  Text "!" <> sub'verbnl <> Text "!"+>+> latexs                        :: Bool -> String -> Doc+> latexs b                      =  catenate . map latex+>     where+>     latex ' '+>         | b                   =  Text "\\char32 "+>     latex c+>         | c `elem` " \t\n"    =  Text "~"+>         | isAlphaNum c        =  Text [c]+>         | otherwise           =  Text ("\\char" ++ show (fromEnum c) ++ "{}")++ks, 11.01.2005: I've added {} after @\char@ to prevent ligatures like+@--@ from applying.++\NB Comments are \emph{not} typeset in \TeX, hence the name of the+style. This is really a feature since the enclosed code need not be+Haskell code.++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Deleting blank lines and expanding tabs}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Delete leading and trailing blank line(s).++> trim                          :: String -> String+> trim                          =  skip .> reverse .> skip .> reverse+>+> skip                          :: String -> String+> skip ""                       =  ""+> skip s | all isSpace t        =  skip u+>        | otherwise            =  s+>        where (t, u)           =  breakAfter (== '\n') s++Expanding tabs (assuming a tabulator width of $8$ characters).++> expand                        :: Int -> String -> String+> expand n []                   =  []+> expand n ('\n' : s)           =  '\n' : expand 0 s+> expand n ('\t' : s)           =  replicate (n' - n) ' ' ++ expand n' s+>     where n'                  =  (n + 8) `div` 8 * 8+> expand n (c : s)              =  c : expand (n + 1) s+
+ Version.lhs.in view
@@ -0,0 +1,53 @@+%if doc+\newcommand\ProgramVersion{@VERSION@}+%else+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Program version information}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> module Version where+>+> import FileNameUtils+> import Data.List+>+> version                       :: String+> version                       =  "@VERSION@"+> numversion                    :: Int+> numversion                    =  @NUMVERSION@++Used internally to distinguish prereleases.++> pre                           :: Int+> pre                           =  @PRE@++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Search path}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> searchPath                    =  relPath ["."] :+>                                  [  deep (relPath (env "HOME":[p ++ x]))+>                                  |  p <- ["","."]+>                                  ,  x <- lhs2TeXNames+>                                  ] +++>                                  [deep (relPath [env "LHS2TEX"])] +++>                                  [  deep (path [dir])+>                                  |  dir  <-  lhs2TeXNames+>                                  ,  path <-  [\x -> relPath ([datadir] ++ x)+>                                              ,\x -> absPath (["usr","local","share"] ++ x)+>                                              ,\x -> absPath (["usr","local","lib"] ++ x)+>                                              ,\x -> absPath (["usr","share"] ++ x)+>                                              ,\x -> absPath (["usr","lib"] ++ x)+>                                              ]+>                                  ]+>+> lhs2TeXNames                  =  ["lhs2tex-@SHORTVERSION@"+>                                  ,"lhs2tex"+>                                  ,"lhs2TeX"+>                                  ]+>+> datadir                       =  replace "@datadir@" "@prefix@"+>   where replace x y  |  "$prefix" `isPrefixOf` x = y ++ drop 7 x+>                      |  "${prefix}" `isPrefixOf` x = y ++ drop 9 x+>                      |  otherwise = x++%endif
+ cata.snip view
@@ -0,0 +1,28 @@+%format map                     = "\textbf{map}"+We start by defining a datatype for constructing fixed points of unary+type constructors:+%format Mu                      = "\mu "+%format In                      = "\textbf{In}"++> data Mu f                     =  In (f (Mu f))++Ideally, we would like to view the |In| constructor as an isomorphism+of |f (Mu f)| and |Mu f| with the inverse isomorphism given by:+%format out     = "\textbf{out}"++> out                           :: Mu f -> f (Mu f) +> out (In x)                    =  x++%format (cata (x))              = "\llparenthesis " x "\rrparenthesis "+%format (ana (x))               = "\llbracket " x "\rrbracket "+%format phi                     = "\varphi "+%format psi                     = "\psi "+The general definitions of catamorphisms and anamorphisms denoted by+|cata phi| and |ana psi| respectively, can be expressed directly in+this framework:++> cata                          :: (Functor m) => (m a -> a) -> (Mu m -> a)+> cata phi                      =  phi . map (cata phi) . out+>+> ana                           :: (Functor m) => (a -> m a) -> (a -> Mu m)+> ana psi                       =  In . map (ana  psi) . psi
+ common.mk view
@@ -0,0 +1,17 @@++.SUFFIXES : .tex .dvi .pdf .ps++.tex.dvi:+	sh -c ' \+	  $(LATEX) $(LATEX_OPTS) $<; \+	  while grep -c "Warning.*Rerun" $(<:.tex=.log); \+	    do $(LATEX) $(LATEX_OPTS) $<; done;'++.tex.pdf:+	sh -c ' \+	  $(PDFLATEX) $(PDFLATEX_OPTS) $<; \+	  while grep -c "Warning.*Rerun" $(<:.tex=.log); \+	    do $(PDFLATEX) $(PDFLATEX_OPTS) $<; done;'++.dvi.ps:+	$(DVIPS) -D600 -o $@ $<
+ config.mk.in view
@@ -0,0 +1,45 @@++PACKAGE_TARNAME := @PACKAGE_TARNAME@+PACKAGE_VERSION := @PACKAGE_VERSION@+DISTDIR         := $(PACKAGE_TARNAME)-$(PACKAGE_VERSION)++bindir          = @bindir@+datadir         = @datadir@+stydir          = @datadir@/@PACKAGE_TARNAME@+docdir          = @docdir@+mandir          = @mandir@+prefix          = @prefix@+exec_prefix     = @exec_prefix@++# binpath	:= $(HOME)/bin++GHC		= @GHC@+# GHCFLAGS	:= -Wall -O -recomp+GHCFLAGS        = -O++HUGS            = @HUGS@++INSTALL         = @INSTALL@+MV              = @MV@+CP              = @CP@+RM              = @RM@+MKDIR           = @MKDIR@+TOUCH           = @TOUCH@+DIFF            = @DIFF@+FIND            = @FIND@+LN_S            = @LN_S@+LATEX           = @LATEX@+PDFLATEX        = @PDFLATEX@+XDVI            = @XDVI@+GV              = @GV@+DVIPS           = @DVIPS@+SED             = @SED@+GREP            = @GREP@+SORT            = @SORT@+UNIQ            = @UNIQ@++polydir         = @texmf@/tex/latex/polytable+texdir          = @texmf@/tex/latex/lhs2tex+INSTALL_POLYTABLE = @POLYTABLE_INSTALL@+MKTEXLSR        = @MKTEXLSR@+
+ configure view
@@ -0,0 +1,3781 @@+#! /bin/sh+# Guess values for system-dependent variables and create Makefiles.+# Generated by GNU Autoconf 2.61 for lhs2tex 1.12.+#+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,+# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.+# This configure script is free software; the Free Software Foundation+# gives unlimited permission to copy, distribute and modify it.+## --------------------- ##+## M4sh Initialization.  ##+## --------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then+  emulate sh+  NULLCMD=:+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which+  # is contrary to our usage.  Disable this feature.+  alias -g '${1+"$@"}'='"$@"'+  setopt NO_GLOB_SUBST+else+  case `(set -o) 2>/dev/null` in+  *posix*) set -o posix ;;+esac++fi+++++# PATH needs CR+# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits++# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+  echo "#! /bin/sh" >conf$$.sh+  echo  "exit 0"   >>conf$$.sh+  chmod +x conf$$.sh+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then+    PATH_SEPARATOR=';'+  else+    PATH_SEPARATOR=:+  fi+  rm -f conf$$.sh+fi++# Support unset when possible.+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then+  as_unset=unset+else+  as_unset=false+fi+++# IFS+# We need space, tab and new line, in precisely that order.  Quoting is+# there to prevent editors from complaining about space-tab.+# (If _AS_PATH_WALK were called with IFS unset, it would disable word+# splitting by setting IFS to empty value.)+as_nl='+'+IFS=" ""	$as_nl"++# Find who we are.  Look in the path if we contain no directory separator.+case $0 in+  *[\\/]* ) as_myself=$0 ;;+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break+done+IFS=$as_save_IFS++     ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+  as_myself=$0+fi+if test ! -f "$as_myself"; then+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+  { (exit 1); exit 1; }+fi++# Work around bugs in pre-3.0 UWIN ksh.+for as_var in ENV MAIL MAILPATH+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var+done+PS1='$ '+PS2='> '+PS4='+ '++# NLS nuisances.+for as_var in \+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \+  LC_TELEPHONE LC_TIME+do+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then+    eval $as_var=C; export $as_var+  else+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var+  fi+done++# Required to use basename.+if expr a : '\(a\)' >/dev/null 2>&1 &&+   test "X`expr 00001 : '.*\(...\)'`" = X001; then+  as_expr=expr+else+  as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+  as_basename=basename+else+  as_basename=false+fi+++# Name of the executable.+as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+	 X"$0" : 'X\(//\)$' \| \+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||+echo X/"$0" |+    sed '/^.*\/\([^/][^/]*\)\/*$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`++# CDPATH.+$as_unset CDPATH+++if test "x$CONFIG_SHELL" = x; then+  if (eval ":") 2>/dev/null; then+  as_have_required=yes+else+  as_have_required=no+fi++  if test $as_have_required = yes && 	 (eval ":+(as_func_return () {+  (exit \$1)+}+as_func_success () {+  as_func_return 0+}+as_func_failure () {+  as_func_return 1+}+as_func_ret_success () {+  return 0+}+as_func_ret_failure () {+  return 1+}++exitcode=0+if as_func_success; then+  :+else+  exitcode=1+  echo as_func_success failed.+fi++if as_func_failure; then+  exitcode=1+  echo as_func_failure succeeded.+fi++if as_func_ret_success; then+  :+else+  exitcode=1+  echo as_func_ret_success failed.+fi++if as_func_ret_failure; then+  exitcode=1+  echo as_func_ret_failure succeeded.+fi++if ( set x; as_func_ret_success y && test x = \"\$1\" ); then+  :+else+  exitcode=1+  echo positional parameters were not saved.+fi++test \$exitcode = 0) || { (exit 1); exit 1; }++(+  as_lineno_1=\$LINENO+  as_lineno_2=\$LINENO+  test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" &&+  test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; }+") 2> /dev/null; then+  :+else+  as_candidate_shells=+    as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  case $as_dir in+	 /*)+	   for as_base in sh bash ksh sh5; do+	     as_candidate_shells="$as_candidate_shells $as_dir/$as_base"+	   done;;+       esac+done+IFS=$as_save_IFS+++      for as_shell in $as_candidate_shells $SHELL; do+	 # Try only shells that exist, to save several forks.+	 if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&+		{ ("$as_shell") 2> /dev/null <<\_ASEOF+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then+  emulate sh+  NULLCMD=:+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which+  # is contrary to our usage.  Disable this feature.+  alias -g '${1+"$@"}'='"$@"'+  setopt NO_GLOB_SUBST+else+  case `(set -o) 2>/dev/null` in+  *posix*) set -o posix ;;+esac++fi+++:+_ASEOF+}; then+  CONFIG_SHELL=$as_shell+	       as_have_required=yes+	       if { "$as_shell" 2> /dev/null <<\_ASEOF+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then+  emulate sh+  NULLCMD=:+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which+  # is contrary to our usage.  Disable this feature.+  alias -g '${1+"$@"}'='"$@"'+  setopt NO_GLOB_SUBST+else+  case `(set -o) 2>/dev/null` in+  *posix*) set -o posix ;;+esac++fi+++:+(as_func_return () {+  (exit $1)+}+as_func_success () {+  as_func_return 0+}+as_func_failure () {+  as_func_return 1+}+as_func_ret_success () {+  return 0+}+as_func_ret_failure () {+  return 1+}++exitcode=0+if as_func_success; then+  :+else+  exitcode=1+  echo as_func_success failed.+fi++if as_func_failure; then+  exitcode=1+  echo as_func_failure succeeded.+fi++if as_func_ret_success; then+  :+else+  exitcode=1+  echo as_func_ret_success failed.+fi++if as_func_ret_failure; then+  exitcode=1+  echo as_func_ret_failure succeeded.+fi++if ( set x; as_func_ret_success y && test x = "$1" ); then+  :+else+  exitcode=1+  echo positional parameters were not saved.+fi++test $exitcode = 0) || { (exit 1); exit 1; }++(+  as_lineno_1=$LINENO+  as_lineno_2=$LINENO+  test "x$as_lineno_1" != "x$as_lineno_2" &&+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; }++_ASEOF+}; then+  break+fi++fi++      done++      if test "x$CONFIG_SHELL" != x; then+  for as_var in BASH_ENV ENV+        do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var+        done+        export CONFIG_SHELL+        exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}+fi+++    if test $as_have_required = no; then+  echo This script requires a shell more modern than all the+      echo shells that I found on your system.  Please install a+      echo modern shell, or manually run the script under such a+      echo shell if you do have one.+      { (exit 1); exit 1; }+fi+++fi++fi++++(eval "as_func_return () {+  (exit \$1)+}+as_func_success () {+  as_func_return 0+}+as_func_failure () {+  as_func_return 1+}+as_func_ret_success () {+  return 0+}+as_func_ret_failure () {+  return 1+}++exitcode=0+if as_func_success; then+  :+else+  exitcode=1+  echo as_func_success failed.+fi++if as_func_failure; then+  exitcode=1+  echo as_func_failure succeeded.+fi++if as_func_ret_success; then+  :+else+  exitcode=1+  echo as_func_ret_success failed.+fi++if as_func_ret_failure; then+  exitcode=1+  echo as_func_ret_failure succeeded.+fi++if ( set x; as_func_ret_success y && test x = \"\$1\" ); then+  :+else+  exitcode=1+  echo positional parameters were not saved.+fi++test \$exitcode = 0") || {+  echo No shell found that supports shell functions.+  echo Please tell autoconf@gnu.org about your system,+  echo including any error possibly output before this+  echo message+}++++  as_lineno_1=$LINENO+  as_lineno_2=$LINENO+  test "x$as_lineno_1" != "x$as_lineno_2" &&+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {++  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO+  # uniformly replaced by the line number.  The first 'sed' inserts a+  # line-number line after each line using $LINENO; the second 'sed'+  # does the real work.  The second script uses 'N' to pair each+  # line-number line with the line containing $LINENO, and appends+  # trailing '-' during substitution so that $LINENO is not a special+  # case at line end.+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the+  # scripts with optimization help from Paolo Bonzini.  Blame Lee+  # E. McMahon (1931-1989) for sed's syntax.  :-)+  sed -n '+    p+    /[$]LINENO/=+  ' <$as_myself |+    sed '+      s/[$]LINENO.*/&-/+      t lineno+      b+      :lineno+      N+      :loop+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/+      t loop+      s/-\n.*//+    ' >$as_me.lineno &&+  chmod +x "$as_me.lineno" ||+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2+   { (exit 1); exit 1; }; }++  # Don't try to exec as it changes $[0], causing all sort of problems+  # (the dirname of $[0] is not the place where we might find the+  # original and so on.  Autoconf is especially sensitive to this).+  . "./$as_me.lineno"+  # Exit status is that of the last command.+  exit+}+++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+  as_dirname=dirname+else+  as_dirname=false+fi++ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in+-n*)+  case `echo 'x\c'` in+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.+  *)   ECHO_C='\c';;+  esac;;+*)+  ECHO_N='-n';;+esac++if expr a : '\(a\)' >/dev/null 2>&1 &&+   test "X`expr 00001 : '.*\(...\)'`" = X001; then+  as_expr=expr+else+  as_expr=false+fi++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+  rm -f conf$$.dir/conf$$.file+else+  rm -f conf$$.dir+  mkdir conf$$.dir+fi+echo >conf$$.file+if ln -s conf$$.file conf$$ 2>/dev/null; then+  as_ln_s='ln -s'+  # ... but there are two gotchas:+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+  # In both cases, we have to default to `cp -p'.+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+    as_ln_s='cp -p'+elif ln conf$$.file conf$$ 2>/dev/null; then+  as_ln_s=ln+else+  as_ln_s='cp -p'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null++if mkdir -p . 2>/dev/null; then+  as_mkdir_p=:+else+  test -d ./-p && rmdir ./-p+  as_mkdir_p=false+fi++if test -x / >/dev/null 2>&1; then+  as_test_x='test -x'+else+  if ls -dL / >/dev/null 2>&1; then+    as_ls_L_option=L+  else+    as_ls_L_option=+  fi+  as_test_x='+    eval sh -c '\''+      if test -d "$1"; then+        test -d "$1/.";+      else+	case $1 in+        -*)set "./$1";;+	esac;+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in+	???[sx]*):;;*)false;;esac;fi+    '\'' sh+  '+fi+as_executable_p=$as_test_x++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"++++exec 7<&0 </dev/null 6>&1++# Name of the host.+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,+# so uname gets run too.+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`++#+# Initializations.+#+ac_default_prefix=/usr/local+ac_clean_files=+ac_config_libobj_dir=.+LIBOBJS=+cross_compiling=no+subdirs=+MFLAGS=+MAKEFLAGS=+SHELL=${CONFIG_SHELL-/bin/sh}++# Identity of this package.+PACKAGE_NAME='lhs2tex'+PACKAGE_TARNAME='lhs2tex'+PACKAGE_VERSION='1.12'+PACKAGE_STRING='lhs2tex 1.12'+PACKAGE_BUGREPORT=''++ac_subst_vars='SHELL+PATH_SEPARATOR+PACKAGE_NAME+PACKAGE_TARNAME+PACKAGE_VERSION+PACKAGE_STRING+PACKAGE_BUGREPORT+exec_prefix+prefix+program_transform_name+bindir+sbindir+libexecdir+datarootdir+datadir+sysconfdir+sharedstatedir+localstatedir+includedir+oldincludedir+docdir+infodir+htmldir+dvidir+pdfdir+psdir+libdir+localedir+mandir+DEFS+ECHO_C+ECHO_N+ECHO_T+LIBS+build_alias+host_alias+target_alias+VERSION+SHORTVERSION+NUMVERSION+PRE+GHC+HUGS+INSTALL_PROGRAM+INSTALL_SCRIPT+INSTALL_DATA+LN_S+MV+CP+RM+MKDIR+TOUCH+DIFF+GREP+SED+SORT+UNIQ+FIND+LATEX+PDFLATEX+XDVI+GV+DVIPS+KPSEWHICH+texmf+POLYTABLE_INSTALL+MKTEXLSR+LHS2TEX+LIBOBJS+LTLIBOBJS'+ac_subst_files=''+      ac_precious_vars='build_alias+host_alias+target_alias'+++# Initialize some variables set by options.+ac_init_help=+ac_init_version=false+# The variables have the same names as the options, with+# dashes changed to underlines.+cache_file=/dev/null+exec_prefix=NONE+no_create=+no_recursion=+prefix=NONE+program_prefix=NONE+program_suffix=NONE+program_transform_name=s,x,x,+silent=+site=+srcdir=+verbose=+x_includes=NONE+x_libraries=NONE++# Installation directory options.+# These are left unexpanded so users can "make install exec_prefix=/foo"+# and all the variables that are supposed to be based on exec_prefix+# by default will actually change.+# Use braces instead of parens because sh, perl, etc. also accept them.+# (The list follows the same order as the GNU Coding Standards.)+bindir='${exec_prefix}/bin'+sbindir='${exec_prefix}/sbin'+libexecdir='${exec_prefix}/libexec'+datarootdir='${prefix}/share'+datadir='${datarootdir}'+sysconfdir='${prefix}/etc'+sharedstatedir='${prefix}/com'+localstatedir='${prefix}/var'+includedir='${prefix}/include'+oldincludedir='/usr/include'+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'+infodir='${datarootdir}/info'+htmldir='${docdir}'+dvidir='${docdir}'+pdfdir='${docdir}'+psdir='${docdir}'+libdir='${exec_prefix}/lib'+localedir='${datarootdir}/locale'+mandir='${datarootdir}/man'++ac_prev=+ac_dashdash=+for ac_option+do+  # If the previous option needs an argument, assign it.+  if test -n "$ac_prev"; then+    eval $ac_prev=\$ac_option+    ac_prev=+    continue+  fi++  case $ac_option in+  *=*)	ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;+  *)	ac_optarg=yes ;;+  esac++  # Accept the important Cygnus configure options, so we can diagnose typos.++  case $ac_dashdash$ac_option in+  --)+    ac_dashdash=yes ;;++  -bindir | --bindir | --bindi | --bind | --bin | --bi)+    ac_prev=bindir ;;+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)+    bindir=$ac_optarg ;;++  -build | --build | --buil | --bui | --bu)+    ac_prev=build_alias ;;+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)+    build_alias=$ac_optarg ;;++  -cache-file | --cache-file | --cache-fil | --cache-fi \+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)+    ac_prev=cache_file ;;+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)+    cache_file=$ac_optarg ;;++  --config-cache | -C)+    cache_file=config.cache ;;++  -datadir | --datadir | --datadi | --datad)+    ac_prev=datadir ;;+  -datadir=* | --datadir=* | --datadi=* | --datad=*)+    datadir=$ac_optarg ;;++  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \+  | --dataroo | --dataro | --datar)+    ac_prev=datarootdir ;;+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)+    datarootdir=$ac_optarg ;;++  -disable-* | --disable-*)+    ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2+   { (exit 1); exit 1; }; }+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`+    eval enable_$ac_feature=no ;;++  -docdir | --docdir | --docdi | --doc | --do)+    ac_prev=docdir ;;+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)+    docdir=$ac_optarg ;;++  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)+    ac_prev=dvidir ;;+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)+    dvidir=$ac_optarg ;;++  -enable-* | --enable-*)+    ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      { echo "$as_me: error: invalid feature name: $ac_feature" >&2+   { (exit 1); exit 1; }; }+    ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'`+    eval enable_$ac_feature=\$ac_optarg ;;++  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \+  | --exec | --exe | --ex)+    ac_prev=exec_prefix ;;+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \+  | --exec=* | --exe=* | --ex=*)+    exec_prefix=$ac_optarg ;;++  -gas | --gas | --ga | --g)+    # Obsolete; use --with-gas.+    with_gas=yes ;;++  -help | --help | --hel | --he | -h)+    ac_init_help=long ;;+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)+    ac_init_help=recursive ;;+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)+    ac_init_help=short ;;++  -host | --host | --hos | --ho)+    ac_prev=host_alias ;;+  -host=* | --host=* | --hos=* | --ho=*)+    host_alias=$ac_optarg ;;++  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)+    ac_prev=htmldir ;;+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \+  | --ht=*)+    htmldir=$ac_optarg ;;++  -includedir | --includedir | --includedi | --included | --include \+  | --includ | --inclu | --incl | --inc)+    ac_prev=includedir ;;+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \+  | --includ=* | --inclu=* | --incl=* | --inc=*)+    includedir=$ac_optarg ;;++  -infodir | --infodir | --infodi | --infod | --info | --inf)+    ac_prev=infodir ;;+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)+    infodir=$ac_optarg ;;++  -libdir | --libdir | --libdi | --libd)+    ac_prev=libdir ;;+  -libdir=* | --libdir=* | --libdi=* | --libd=*)+    libdir=$ac_optarg ;;++  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \+  | --libexe | --libex | --libe)+    ac_prev=libexecdir ;;+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \+  | --libexe=* | --libex=* | --libe=*)+    libexecdir=$ac_optarg ;;++  -localedir | --localedir | --localedi | --localed | --locale)+    ac_prev=localedir ;;+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)+    localedir=$ac_optarg ;;++  -localstatedir | --localstatedir | --localstatedi | --localstated \+  | --localstate | --localstat | --localsta | --localst | --locals)+    ac_prev=localstatedir ;;+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)+    localstatedir=$ac_optarg ;;++  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)+    ac_prev=mandir ;;+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)+    mandir=$ac_optarg ;;++  -nfp | --nfp | --nf)+    # Obsolete; use --without-fp.+    with_fp=no ;;++  -no-create | --no-create | --no-creat | --no-crea | --no-cre \+  | --no-cr | --no-c | -n)+    no_create=yes ;;++  -no-recursion | --no-recursion | --no-recursio | --no-recursi \+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)+    no_recursion=yes ;;++  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \+  | --oldin | --oldi | --old | --ol | --o)+    ac_prev=oldincludedir ;;+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)+    oldincludedir=$ac_optarg ;;++  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)+    ac_prev=prefix ;;+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)+    prefix=$ac_optarg ;;++  -program-prefix | --program-prefix | --program-prefi | --program-pref \+  | --program-pre | --program-pr | --program-p)+    ac_prev=program_prefix ;;+  -program-prefix=* | --program-prefix=* | --program-prefi=* \+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)+    program_prefix=$ac_optarg ;;++  -program-suffix | --program-suffix | --program-suffi | --program-suff \+  | --program-suf | --program-su | --program-s)+    ac_prev=program_suffix ;;+  -program-suffix=* | --program-suffix=* | --program-suffi=* \+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)+    program_suffix=$ac_optarg ;;++  -program-transform-name | --program-transform-name \+  | --program-transform-nam | --program-transform-na \+  | --program-transform-n | --program-transform- \+  | --program-transform | --program-transfor \+  | --program-transfo | --program-transf \+  | --program-trans | --program-tran \+  | --progr-tra | --program-tr | --program-t)+    ac_prev=program_transform_name ;;+  -program-transform-name=* | --program-transform-name=* \+  | --program-transform-nam=* | --program-transform-na=* \+  | --program-transform-n=* | --program-transform-=* \+  | --program-transform=* | --program-transfor=* \+  | --program-transfo=* | --program-transf=* \+  | --program-trans=* | --program-tran=* \+  | --progr-tra=* | --program-tr=* | --program-t=*)+    program_transform_name=$ac_optarg ;;++  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)+    ac_prev=pdfdir ;;+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)+    pdfdir=$ac_optarg ;;++  -psdir | --psdir | --psdi | --psd | --ps)+    ac_prev=psdir ;;+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)+    psdir=$ac_optarg ;;++  -q | -quiet | --quiet | --quie | --qui | --qu | --q \+  | -silent | --silent | --silen | --sile | --sil)+    silent=yes ;;++  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)+    ac_prev=sbindir ;;+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \+  | --sbi=* | --sb=*)+    sbindir=$ac_optarg ;;++  -sharedstatedir | --sharedstatedir | --sharedstatedi \+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \+  | --sharedst | --shareds | --shared | --share | --shar \+  | --sha | --sh)+    ac_prev=sharedstatedir ;;+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \+  | --sha=* | --sh=*)+    sharedstatedir=$ac_optarg ;;++  -site | --site | --sit)+    ac_prev=site ;;+  -site=* | --site=* | --sit=*)+    site=$ac_optarg ;;++  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)+    ac_prev=srcdir ;;+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)+    srcdir=$ac_optarg ;;++  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \+  | --syscon | --sysco | --sysc | --sys | --sy)+    ac_prev=sysconfdir ;;+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)+    sysconfdir=$ac_optarg ;;++  -target | --target | --targe | --targ | --tar | --ta | --t)+    ac_prev=target_alias ;;+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)+    target_alias=$ac_optarg ;;++  -v | -verbose | --verbose | --verbos | --verbo | --verb)+    verbose=yes ;;++  -version | --version | --versio | --versi | --vers | -V)+    ac_init_version=: ;;++  -with-* | --with-*)+    ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      { echo "$as_me: error: invalid package name: $ac_package" >&2+   { (exit 1); exit 1; }; }+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`+    eval with_$ac_package=\$ac_optarg ;;++  -without-* | --without-*)+    ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      { echo "$as_me: error: invalid package name: $ac_package" >&2+   { (exit 1); exit 1; }; }+    ac_package=`echo $ac_package | sed 's/[-.]/_/g'`+    eval with_$ac_package=no ;;++  --x)+    # Obsolete; use --with-x.+    with_x=yes ;;++  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \+  | --x-incl | --x-inc | --x-in | --x-i)+    ac_prev=x_includes ;;+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)+    x_includes=$ac_optarg ;;++  -x-libraries | --x-libraries | --x-librarie | --x-librari \+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)+    ac_prev=x_libraries ;;+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)+    x_libraries=$ac_optarg ;;++  -*) { echo "$as_me: error: unrecognized option: $ac_option+Try \`$0 --help' for more information." >&2+   { (exit 1); exit 1; }; }+    ;;++  *=*)+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`+    # Reject names that are not valid shell variable names.+    expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null &&+      { echo "$as_me: error: invalid variable name: $ac_envvar" >&2+   { (exit 1); exit 1; }; }+    eval $ac_envvar=\$ac_optarg+    export $ac_envvar ;;++  *)+    # FIXME: should be removed in autoconf 3.0.+    echo "$as_me: WARNING: you should use --build, --host, --target" >&2+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      echo "$as_me: WARNING: invalid host type: $ac_option" >&2+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}+    ;;++  esac+done++if test -n "$ac_prev"; then+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`+  { echo "$as_me: error: missing argument to $ac_option" >&2+   { (exit 1); exit 1; }; }+fi++# Be sure to have absolute directory names.+for ac_var in	exec_prefix prefix bindir sbindir libexecdir datarootdir \+		datadir sysconfdir sharedstatedir localstatedir includedir \+		oldincludedir docdir infodir htmldir dvidir pdfdir psdir \+		libdir localedir mandir+do+  eval ac_val=\$$ac_var+  case $ac_val in+    [\\/$]* | ?:[\\/]* )  continue;;+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;+  esac+  { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2+   { (exit 1); exit 1; }; }+done++# There might be people who depend on the old broken behavior: `$host'+# used to hold the argument of --host etc.+# FIXME: To remove some day.+build=$build_alias+host=$host_alias+target=$target_alias++# FIXME: To remove some day.+if test "x$host_alias" != x; then+  if test "x$build_alias" = x; then+    cross_compiling=maybe+    echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.+    If a cross compiler is detected then cross compile mode will be used." >&2+  elif test "x$build_alias" != "x$host_alias"; then+    cross_compiling=yes+  fi+fi++ac_tool_prefix=+test -n "$host_alias" && ac_tool_prefix=$host_alias-++test "$silent" = yes && exec 6>/dev/null+++ac_pwd=`pwd` && test -n "$ac_pwd" &&+ac_ls_di=`ls -di .` &&+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||+  { echo "$as_me: error: Working directory cannot be determined" >&2+   { (exit 1); exit 1; }; }+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||+  { echo "$as_me: error: pwd does not report name of working directory" >&2+   { (exit 1); exit 1; }; }+++# Find the source files, if location was not specified.+if test -z "$srcdir"; then+  ac_srcdir_defaulted=yes+  # Try the directory containing this script, then the parent directory.+  ac_confdir=`$as_dirname -- "$0" ||+$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+	 X"$0" : 'X\(//\)[^/]' \| \+	 X"$0" : 'X\(//\)$' \| \+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||+echo X"$0" |+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)[^/].*/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`+  srcdir=$ac_confdir+  if test ! -r "$srcdir/$ac_unique_file"; then+    srcdir=..+  fi+else+  ac_srcdir_defaulted=no+fi+if test ! -r "$srcdir/$ac_unique_file"; then+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."+  { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2+   { (exit 1); exit 1; }; }+fi+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"+ac_abs_confdir=`(+	cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2+   { (exit 1); exit 1; }; }+	pwd)`+# When building in place, set srcdir=.+if test "$ac_abs_confdir" = "$ac_pwd"; then+  srcdir=.+fi+# Remove unnecessary trailing slashes from srcdir.+# Double slashes in file names in object file debugging info+# mess up M-x gdb in Emacs.+case $srcdir in+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;+esac+for ac_var in $ac_precious_vars; do+  eval ac_env_${ac_var}_set=\${${ac_var}+set}+  eval ac_env_${ac_var}_value=\$${ac_var}+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}+  eval ac_cv_env_${ac_var}_value=\$${ac_var}+done++#+# Report the --help message.+#+if test "$ac_init_help" = "long"; then+  # Omit some internal or obsolete options to make the list less imposing.+  # This message is too long to be a string in the A/UX 3.1 sh.+  cat <<_ACEOF+\`configure' configures lhs2tex 1.12 to adapt to many kinds of systems.++Usage: $0 [OPTION]... [VAR=VALUE]...++To assign environment variables (e.g., CC, CFLAGS...), specify them as+VAR=VALUE.  See below for descriptions of some of the useful variables.++Defaults for the options are specified in brackets.++Configuration:+  -h, --help              display this help and exit+      --help=short        display options specific to this package+      --help=recursive    display the short help of all the included packages+  -V, --version           display version information and exit+  -q, --quiet, --silent   do not print \`checking...' messages+      --cache-file=FILE   cache test results in FILE [disabled]+  -C, --config-cache      alias for \`--cache-file=config.cache'+  -n, --no-create         do not create output files+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']++Installation directories:+  --prefix=PREFIX         install architecture-independent files in PREFIX+			  [$ac_default_prefix]+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX+			  [PREFIX]++By default, \`make install' will install all the files in+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify+an installation prefix other than \`$ac_default_prefix' using \`--prefix',+for instance \`--prefix=\$HOME'.++For better control, use the options below.++Fine tuning of the installation directories:+  --bindir=DIR           user executables [EPREFIX/bin]+  --sbindir=DIR          system admin executables [EPREFIX/sbin]+  --libexecdir=DIR       program executables [EPREFIX/libexec]+  --sysconfdir=DIR       read-only single-machine data [PREFIX/etc]+  --sharedstatedir=DIR   modifiable architecture-independent data [PREFIX/com]+  --localstatedir=DIR    modifiable single-machine data [PREFIX/var]+  --libdir=DIR           object code libraries [EPREFIX/lib]+  --includedir=DIR       C header files [PREFIX/include]+  --oldincludedir=DIR    C header files for non-gcc [/usr/include]+  --datarootdir=DIR      read-only arch.-independent data root [PREFIX/share]+  --datadir=DIR          read-only architecture-independent data [DATAROOTDIR]+  --infodir=DIR          info documentation [DATAROOTDIR/info]+  --localedir=DIR        locale-dependent data [DATAROOTDIR/locale]+  --mandir=DIR           man documentation [DATAROOTDIR/man]+  --docdir=DIR           documentation root [DATAROOTDIR/doc/lhs2tex]+  --htmldir=DIR          html documentation [DOCDIR]+  --dvidir=DIR           dvi documentation [DOCDIR]+  --pdfdir=DIR           pdf documentation [DOCDIR]+  --psdir=DIR            ps documentation [DOCDIR]+_ACEOF++  cat <<\_ACEOF+_ACEOF+fi++if test -n "$ac_init_help"; then+  case $ac_init_help in+     short | recursive ) echo "Configuration of lhs2tex 1.12:";;+   esac+  cat <<\_ACEOF++Optional Features:+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]+  --disable-polytable     do not install polytable TeX package++Optional Packages:+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)+  --with-texmf=DIR        path to an existing texmf tree [$TEXMFLOCAL]++_ACEOF+ac_status=$?+fi++if test "$ac_init_help" = "recursive"; then+  # If there are subdirs, report their specific --help.+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue+    test -d "$ac_dir" || continue+    ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`+  # A ".." for each directory in $ac_dir_suffix.+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`+  case $ac_top_builddir_sub in+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;+  esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+  .)  # We are building in place.+    ac_srcdir=.+    ac_top_srcdir=$ac_top_builddir_sub+    ac_abs_top_srcdir=$ac_pwd ;;+  [\\/]* | ?:[\\/]* )  # Absolute name.+    ac_srcdir=$srcdir$ac_dir_suffix;+    ac_top_srcdir=$srcdir+    ac_abs_top_srcdir=$srcdir ;;+  *) # Relative name.+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+    ac_top_srcdir=$ac_top_build_prefix$srcdir+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix++    cd "$ac_dir" || { ac_status=$?; continue; }+    # Check for guested configure.+    if test -f "$ac_srcdir/configure.gnu"; then+      echo &&+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive+    elif test -f "$ac_srcdir/configure"; then+      echo &&+      $SHELL "$ac_srcdir/configure" --help=recursive+    else+      echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2+    fi || ac_status=$?+    cd "$ac_pwd" || { ac_status=$?; break; }+  done+fi++test -n "$ac_init_help" && exit $ac_status+if $ac_init_version; then+  cat <<\_ACEOF+lhs2tex configure 1.12+generated by GNU Autoconf 2.61++Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,+2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.+This configure script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it.+_ACEOF+  exit+fi+cat >config.log <<_ACEOF+This file contains any messages produced by compilers while+running configure, to aid debugging if configure makes a mistake.++It was created by lhs2tex $as_me 1.12, which was+generated by GNU Autoconf 2.61.  Invocation command line was++  $ $0 $@++_ACEOF+exec 5>>config.log+{+cat <<_ASUNAME+## --------- ##+## Platform. ##+## --------- ##++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`+uname -m = `(uname -m) 2>/dev/null || echo unknown`+uname -r = `(uname -r) 2>/dev/null || echo unknown`+uname -s = `(uname -s) 2>/dev/null || echo unknown`+uname -v = `(uname -v) 2>/dev/null || echo unknown`++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`++/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`++_ASUNAME++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  echo "PATH: $as_dir"+done+IFS=$as_save_IFS++} >&5++cat >&5 <<_ACEOF+++## ----------- ##+## Core tests. ##+## ----------- ##++_ACEOF+++# Keep a trace of the command line.+# Strip out --no-create and --no-recursion so they do not pile up.+# Strip out --silent because we don't want to record it for future runs.+# Also quote any args containing shell meta-characters.+# Make two passes to allow for proper duplicate-argument suppression.+ac_configure_args=+ac_configure_args0=+ac_configure_args1=+ac_must_keep_next=false+for ac_pass in 1 2+do+  for ac_arg+  do+    case $ac_arg in+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \+    | -silent | --silent | --silen | --sile | --sil)+      continue ;;+    *\'*)+      ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+    esac+    case $ac_pass in+    1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;;+    2)+      ac_configure_args1="$ac_configure_args1 '$ac_arg'"+      if test $ac_must_keep_next = true; then+	ac_must_keep_next=false # Got value, back to normal.+      else+	case $ac_arg in+	  *=* | --config-cache | -C | -disable-* | --disable-* \+	  | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \+	  | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \+	  | -with-* | --with-* | -without-* | --without-* | --x)+	    case "$ac_configure_args0 " in+	      "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;+	    esac+	    ;;+	  -* ) ac_must_keep_next=true ;;+	esac+      fi+      ac_configure_args="$ac_configure_args '$ac_arg'"+      ;;+    esac+  done+done+$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; }+$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; }++# When interrupted or exit'd, cleanup temporary files, and complete+# config.log.  We remove comments because anyway the quotes in there+# would cause problems or look ugly.+# WARNING: Use '\'' to represent an apostrophe within the trap.+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.+trap 'exit_status=$?+  # Save into config.log some information that might help in debugging.+  {+    echo++    cat <<\_ASBOX+## ---------------- ##+## Cache variables. ##+## ---------------- ##+_ASBOX+    echo+    # The following way of writing the cache mishandles newlines in values,+(+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do+    eval ac_val=\$$ac_var+    case $ac_val in #(+    *${as_nl}*)+      case $ac_var in #(+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;+      esac+      case $ac_var in #(+      _ | IFS | as_nl) ;; #(+      *) $as_unset $ac_var ;;+      esac ;;+    esac+  done+  (set) 2>&1 |+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(+    *${as_nl}ac_space=\ *)+      sed -n \+	"s/'\''/'\''\\\\'\'''\''/g;+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"+      ;; #(+    *)+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+      ;;+    esac |+    sort+)+    echo++    cat <<\_ASBOX+## ----------------- ##+## Output variables. ##+## ----------------- ##+_ASBOX+    echo+    for ac_var in $ac_subst_vars+    do+      eval ac_val=\$$ac_var+      case $ac_val in+      *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+      esac+      echo "$ac_var='\''$ac_val'\''"+    done | sort+    echo++    if test -n "$ac_subst_files"; then+      cat <<\_ASBOX+## ------------------- ##+## File substitutions. ##+## ------------------- ##+_ASBOX+      echo+      for ac_var in $ac_subst_files+      do+	eval ac_val=\$$ac_var+	case $ac_val in+	*\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+	esac+	echo "$ac_var='\''$ac_val'\''"+      done | sort+      echo+    fi++    if test -s confdefs.h; then+      cat <<\_ASBOX+## ----------- ##+## confdefs.h. ##+## ----------- ##+_ASBOX+      echo+      cat confdefs.h+      echo+    fi+    test "$ac_signal" != 0 &&+      echo "$as_me: caught signal $ac_signal"+    echo "$as_me: exit $exit_status"+  } >&5+  rm -f core *.core core.conftest.* &&+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&+    exit $exit_status+' 0+for ac_signal in 1 2 13 15; do+  trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal+done+ac_signal=0++# confdefs.h avoids OS command line length limits that DEFS can exceed.+rm -f -r conftest* confdefs.h++# Predefined preprocessor variables.++cat >>confdefs.h <<_ACEOF+#define PACKAGE_NAME "$PACKAGE_NAME"+_ACEOF+++cat >>confdefs.h <<_ACEOF+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"+_ACEOF+++cat >>confdefs.h <<_ACEOF+#define PACKAGE_VERSION "$PACKAGE_VERSION"+_ACEOF+++cat >>confdefs.h <<_ACEOF+#define PACKAGE_STRING "$PACKAGE_STRING"+_ACEOF+++cat >>confdefs.h <<_ACEOF+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"+_ACEOF+++# Let the site file select an alternate cache file if it wants to.+# Prefer explicitly selected file to automatically selected ones.+if test -n "$CONFIG_SITE"; then+  set x "$CONFIG_SITE"+elif test "x$prefix" != xNONE; then+  set x "$prefix/share/config.site" "$prefix/etc/config.site"+else+  set x "$ac_default_prefix/share/config.site" \+	"$ac_default_prefix/etc/config.site"+fi+shift+for ac_site_file+do+  if test -r "$ac_site_file"; then+    { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5+echo "$as_me: loading site script $ac_site_file" >&6;}+    sed 's/^/| /' "$ac_site_file" >&5+    . "$ac_site_file"+  fi+done++if test -r "$cache_file"; then+  # Some versions of bash will fail to source /dev/null (special+  # files actually), so we avoid doing that.+  if test -f "$cache_file"; then+    { echo "$as_me:$LINENO: loading cache $cache_file" >&5+echo "$as_me: loading cache $cache_file" >&6;}+    case $cache_file in+      [\\/]* | ?:[\\/]* ) . "$cache_file";;+      *)                      . "./$cache_file";;+    esac+  fi+else+  { echo "$as_me:$LINENO: creating cache $cache_file" >&5+echo "$as_me: creating cache $cache_file" >&6;}+  >$cache_file+fi++# Check that the precious variables saved in the cache have kept the same+# value.+ac_cache_corrupted=false+for ac_var in $ac_precious_vars; do+  eval ac_old_set=\$ac_cv_env_${ac_var}_set+  eval ac_new_set=\$ac_env_${ac_var}_set+  eval ac_old_val=\$ac_cv_env_${ac_var}_value+  eval ac_new_val=\$ac_env_${ac_var}_value+  case $ac_old_set,$ac_new_set in+    set,)+      { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5+echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}+      ac_cache_corrupted=: ;;+    ,set)+      { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5+echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}+      ac_cache_corrupted=: ;;+    ,);;+    *)+      if test "x$ac_old_val" != "x$ac_new_val"; then+	{ echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5+echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}+	{ echo "$as_me:$LINENO:   former value:  $ac_old_val" >&5+echo "$as_me:   former value:  $ac_old_val" >&2;}+	{ echo "$as_me:$LINENO:   current value: $ac_new_val" >&5+echo "$as_me:   current value: $ac_new_val" >&2;}+	ac_cache_corrupted=:+      fi;;+  esac+  # Pass precious variables to config.status.+  if test "$ac_new_set" = set; then+    case $ac_new_val in+    *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;+    *) ac_arg=$ac_var=$ac_new_val ;;+    esac+    case " $ac_configure_args " in+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.+      *) ac_configure_args="$ac_configure_args '$ac_arg'" ;;+    esac+  fi+done+if $ac_cache_corrupted; then+  { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5+echo "$as_me: error: changes in the environment can compromise the build" >&2;}+  { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5+echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;}+   { (exit 1); exit 1; }; }+fi++++++++++++++++++++++++++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++++VERSION="1.12"+SHORTVERSION="1.12"+NUMVERSION=112+PRE=3++++++# check for Haskell compiler+# Extract the first word of "ghc", so it can be a program name with args.+set dummy ghc; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_GHC+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $GHC in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_GHC="$GHC" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_GHC="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+GHC=$ac_cv_path_GHC+if test -n "$GHC"; then+  { echo "$as_me:$LINENO: result: $GHC" >&5+echo "${ECHO_T}$GHC" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# check for Hugs (only for documentation)+# Extract the first word of "hugs", so it can be a program name with args.+set dummy hugs; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_HUGS+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $HUGS in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_HUGS="$HUGS" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_HUGS="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+HUGS=$ac_cv_path_HUGS+if test -n "$HUGS"; then+  { echo "$as_me:$LINENO: result: $HUGS" >&5+echo "${ECHO_T}$HUGS" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi++++# install command+ac_aux_dir=+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do+  if test -f "$ac_dir/install-sh"; then+    ac_aux_dir=$ac_dir+    ac_install_sh="$ac_aux_dir/install-sh -c"+    break+  elif test -f "$ac_dir/install.sh"; then+    ac_aux_dir=$ac_dir+    ac_install_sh="$ac_aux_dir/install.sh -c"+    break+  elif test -f "$ac_dir/shtool"; then+    ac_aux_dir=$ac_dir+    ac_install_sh="$ac_aux_dir/shtool install -c"+    break+  fi+done+if test -z "$ac_aux_dir"; then+  { { echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5+echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;}+   { (exit 1); exit 1; }; }+fi++# These three variables are undocumented and unsupported,+# and are intended to be withdrawn in a future Autoconf release.+# They can cause serious problems if a builder's source tree is in a directory+# whose full name contains unusual characters.+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.+++# Find a good install program.  We prefer a C program (faster),+# so one script is as good as another.  But avoid the broken or+# incompatible versions:+# SysV /etc/install, /usr/sbin/install+# SunOS /usr/etc/install+# IRIX /sbin/install+# AIX /bin/install+# AmigaOS /C/install, which installs bootblocks on floppy discs+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag+# AFS /usr/afsws/bin/install, which mishandles nonexistent args+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"+# OS/2's system install, which has a completely different semantic+# ./install, which can be erroneously created by make from ./install.sh.+{ echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5+echo $ECHO_N "checking for a BSD-compatible install... $ECHO_C" >&6; }+if test -z "$INSTALL"; then+if test "${ac_cv_path_install+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  # Account for people who put trailing slashes in PATH elements.+case $as_dir/ in+  ./ | .// | /cC/* | \+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \+  ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \+  /usr/ucb/* ) ;;+  *)+    # OSF1 and SCO ODT 3.0 have their own names for install.+    # Don't use installbsd from OSF since it installs stuff as root+    # by default.+    for ac_prog in ginstall scoinst install; do+      for ac_exec_ext in '' $ac_executable_extensions; do+	if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then+	  if test $ac_prog = install &&+	    grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then+	    # AIX install.  It has an incompatible calling convention.+	    :+	  elif test $ac_prog = install &&+	    grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then+	    # program-specific install script used by HP pwplus--don't use.+	    :+	  else+	    ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"+	    break 3+	  fi+	fi+      done+    done+    ;;+esac+done+IFS=$as_save_IFS+++fi+  if test "${ac_cv_path_install+set}" = set; then+    INSTALL=$ac_cv_path_install+  else+    # As a last resort, use the slow shell script.  Don't cache a+    # value for INSTALL within a source directory, because that will+    # break other packages using the cache if that directory is+    # removed, or if the value is a relative name.+    INSTALL=$ac_install_sh+  fi+fi+{ echo "$as_me:$LINENO: result: $INSTALL" >&5+echo "${ECHO_T}$INSTALL" >&6; }++# Use test -z because SunOS4 sh mishandles braces in ${var-val}.+# It thinks the first close brace ends the variable substitution.+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'++test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'++test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'+++# symbolic links+{ echo "$as_me:$LINENO: checking whether ln -s works" >&5+echo $ECHO_N "checking whether ln -s works... $ECHO_C" >&6; }+LN_S=$as_ln_s+if test "$LN_S" = "ln -s"; then+  { echo "$as_me:$LINENO: result: yes" >&5+echo "${ECHO_T}yes" >&6; }+else+  { echo "$as_me:$LINENO: result: no, using $LN_S" >&5+echo "${ECHO_T}no, using $LN_S" >&6; }+fi+++# other programs+# Extract the first word of "mv", so it can be a program name with args.+set dummy mv; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_MV+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $MV in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_MV="$MV" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_MV="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+MV=$ac_cv_path_MV+if test -n "$MV"; then+  { echo "$as_me:$LINENO: result: $MV" >&5+echo "${ECHO_T}$MV" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "cp", so it can be a program name with args.+set dummy cp; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_CP+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $CP in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_CP="$CP" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_CP="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+CP=$ac_cv_path_CP+if test -n "$CP"; then+  { echo "$as_me:$LINENO: result: $CP" >&5+echo "${ECHO_T}$CP" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "rm", so it can be a program name with args.+set dummy rm; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_RM+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $RM in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_RM="$RM" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_RM="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+RM=$ac_cv_path_RM+if test -n "$RM"; then+  { echo "$as_me:$LINENO: result: $RM" >&5+echo "${ECHO_T}$RM" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "mkdir", so it can be a program name with args.+set dummy mkdir; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_MKDIR+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $MKDIR in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_MKDIR="$MKDIR" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_MKDIR="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+MKDIR=$ac_cv_path_MKDIR+if test -n "$MKDIR"; then+  { echo "$as_me:$LINENO: result: $MKDIR" >&5+echo "${ECHO_T}$MKDIR" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "touch", so it can be a program name with args.+set dummy touch; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_TOUCH+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $TOUCH in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_TOUCH="$TOUCH" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_TOUCH="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+TOUCH=$ac_cv_path_TOUCH+if test -n "$TOUCH"; then+  { echo "$as_me:$LINENO: result: $TOUCH" >&5+echo "${ECHO_T}$TOUCH" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "diff", so it can be a program name with args.+set dummy diff; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_DIFF+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $DIFF in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_DIFF="$DIFF" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_DIFF="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+DIFF=$ac_cv_path_DIFF+if test -n "$DIFF"; then+  { echo "$as_me:$LINENO: result: $DIFF" >&5+echo "${ECHO_T}$DIFF" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "grep", so it can be a program name with args.+set dummy grep; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_GREP+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $GREP in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_GREP="$GREP" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_GREP="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+GREP=$ac_cv_path_GREP+if test -n "$GREP"; then+  { echo "$as_me:$LINENO: result: $GREP" >&5+echo "${ECHO_T}$GREP" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "sed", so it can be a program name with args.+set dummy sed; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_SED+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $SED in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_SED="$SED" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_SED="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+SED=$ac_cv_path_SED+if test -n "$SED"; then+  { echo "$as_me:$LINENO: result: $SED" >&5+echo "${ECHO_T}$SED" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "sort", so it can be a program name with args.+set dummy sort; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_SORT+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $SORT in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_SORT="$SORT" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_SORT="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+SORT=$ac_cv_path_SORT+if test -n "$SORT"; then+  { echo "$as_me:$LINENO: result: $SORT" >&5+echo "${ECHO_T}$SORT" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "uniq", so it can be a program name with args.+set dummy uniq; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_UNIQ+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $UNIQ in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_UNIQ="$UNIQ" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_UNIQ="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+UNIQ=$ac_cv_path_UNIQ+if test -n "$UNIQ"; then+  { echo "$as_me:$LINENO: result: $UNIQ" >&5+echo "${ECHO_T}$UNIQ" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "find", so it can be a program name with args.+set dummy find; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_FIND+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $FIND in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_FIND="$FIND" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_FIND="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+FIND=$ac_cv_path_FIND+if test -n "$FIND"; then+  { echo "$as_me:$LINENO: result: $FIND" >&5+echo "${ECHO_T}$FIND" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "latex", so it can be a program name with args.+set dummy latex; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_LATEX+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $LATEX in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_LATEX="$LATEX" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_LATEX="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+LATEX=$ac_cv_path_LATEX+if test -n "$LATEX"; then+  { echo "$as_me:$LINENO: result: $LATEX" >&5+echo "${ECHO_T}$LATEX" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "pdflatex", so it can be a program name with args.+set dummy pdflatex; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_PDFLATEX+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $PDFLATEX in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_PDFLATEX="$PDFLATEX" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_PDFLATEX="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+PDFLATEX=$ac_cv_path_PDFLATEX+if test -n "$PDFLATEX"; then+  { echo "$as_me:$LINENO: result: $PDFLATEX" >&5+echo "${ECHO_T}$PDFLATEX" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "xdvi", so it can be a program name with args.+set dummy xdvi; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_XDVI+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $XDVI in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_XDVI="$XDVI" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_XDVI="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+XDVI=$ac_cv_path_XDVI+if test -n "$XDVI"; then+  { echo "$as_me:$LINENO: result: $XDVI" >&5+echo "${ECHO_T}$XDVI" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "gv", so it can be a program name with args.+set dummy gv; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_GV+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $GV in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_GV="$GV" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_GV="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+GV=$ac_cv_path_GV+if test -n "$GV"; then+  { echo "$as_me:$LINENO: result: $GV" >&5+echo "${ECHO_T}$GV" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++# Extract the first word of "dvips", so it can be a program name with args.+set dummy dvips; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_DVIPS+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $DVIPS in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_DVIPS="$DVIPS" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_DVIPS="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+DVIPS=$ac_cv_path_DVIPS+if test -n "$DVIPS"; then+  { echo "$as_me:$LINENO: result: $DVIPS" >&5+echo "${ECHO_T}$DVIPS" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi++++# texmf tree+++# Check whether --with-texmf was given.+if test "${with_texmf+set}" = set; then+  withval=$with_texmf; case "$withval" in+    yes|no) texmf= ;;+    *) texmf="$withval" ;;+  esac+fi++# Extract the first word of "kpsewhich", so it can be a program name with args.+set dummy kpsewhich; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_KPSEWHICH+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $KPSEWHICH in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_KPSEWHICH="$KPSEWHICH" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_KPSEWHICH="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+KPSEWHICH=$ac_cv_path_KPSEWHICH+if test -n "$KPSEWHICH"; then+  { echo "$as_me:$LINENO: result: $KPSEWHICH" >&5+echo "${ECHO_T}$KPSEWHICH" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi+++if test -z "$texmf"; then+  { echo "$as_me:$LINENO: checking for a texmf tree" >&5+echo $ECHO_N "checking for a texmf tree... $ECHO_C" >&6; }+  # If user did not specify something, try it ourselves+  if test "${ac_cv_texmf_tree+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else++  if test -x "$KPSEWHICH"; then+    ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFLOCAL'`+    if test -z "$ac_cv_texmf_tree"; then+      ac_cv_texmf_tree=`$KPSEWHICH --expand-var='$TEXMFMAIN'`+    fi+  fi+  if test -z "$ac_cv_texmf_tree"; then+    # try some common paths+    for i in /usr/share/texmf /usr/local/share/texmf; do+      if test -d $$i; then+        ac_cv_texmf_tree=$$i+        break+      fi+    done+  fi++fi++  { echo "$as_me:$LINENO: result: $ac_cv_texmf_tree" >&5+echo "${ECHO_T}$ac_cv_texmf_tree" >&6; }+  texmf="$ac_cv_texmf_tree"+else+  ac_cv_texmf_tree="$texmf"+fi+if test -n "$texmf"; then++cat >>confdefs.h <<_ACEOF+#define TEXMFTOP "$texmf"+_ACEOF++  { echo "$as_me:$LINENO: checking for texmf.cnf" >&5+echo $ECHO_N "checking for texmf.cnf... $ECHO_C" >&6; }+  if test -x "$KPSEWHICH"; then+    texmfcnf="`$KPSEWHICH --format=web2c texmf.cnf`"+  fi+  if test -z "$texmfcnf"; then+    texmfcnf="$texmf/web2c/texmf.cnf"+  fi+  if test -f "$texmfcnf"; then+    { echo "$as_me:$LINENO: result: yes" >&5+echo "${ECHO_T}yes" >&6; }++cat >>confdefs.h <<_ACEOF+#define TEXMF_IS_WEB2C 1+_ACEOF++    texmf_is_web2c=yes+  else+    { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+    texmf_is_web2c=no+  fi+fi+++# Check whether --enable-polytable was given.+if test "${enable_polytable+set}" = set; then+  enableval=$enable_polytable; POLYTABLE_INSTALL=$enableval+else+  POLYTABLE_INSTALL=yes+fi++if test "z$POLYTABLE_INSTALL" = "zyes"; then++{ echo "$as_me:$LINENO: checking for the polytable package" >&5+echo $ECHO_N "checking for the polytable package... $ECHO_C" >&6; }+if test -x "$KPSEWHICH"; then+  POLYTABLE="`$KPSEWHICH polytable.sty`"+fi+if test -f "$POLYTABLE"; then+  { echo "$as_me:$LINENO: result: $POLYTABLE" >&5+echo "${ECHO_T}$POLYTABLE" >&6; }+  { echo "$as_me:$LINENO: checking for version of polytable" >&5+echo $ECHO_N "checking for version of polytable... $ECHO_C" >&6; }+  POLYTABLE_VERSION=`$GREP " v.* .polytable. package" $POLYTABLE | $SED -e "s/^.*v\(.*\) .polytable. package.*$/\1/"`+  { echo "$as_me:$LINENO: result: $POLYTABLE_VERSION" >&5+echo "${ECHO_T}$POLYTABLE_VERSION" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi++  # does polytable need to be installed?+  { echo "$as_me:$LINENO: checking whether polytable needs to be installed" >&5+echo $ECHO_N "checking whether polytable needs to be installed... $ECHO_C" >&6; }+  POLYTABLE_INSTALL=no+  if test -n $POLYTABLE; then+    if ( IFS=".";+      a="$POLYTABLE_VERSION";  b="0.8.2";+      while test -n "$a$b"+      do+              set -- $a;  h1="$1";  shift 2>/dev/null;  a="$*"+              set -- $b;  h2="$1";  shift 2>/dev/null;  b="$*"+              test -n "$h1" || h1=0;  test -n "$h2" || h2=0+              test ${h1} -eq ${h2} || break+      done+      test ${h1} -lt ${h2}+    )+then+  POLYTABLE_INSTALL=yes++fi++  else+    POLYTABLE_INSTALL=yes+  fi+  { echo "$as_me:$LINENO: result: $POLYTABLE_INSTALL" >&5+echo "${ECHO_T}$POLYTABLE_INSTALL" >&6; }+fi++# Extract the first word of "mktexlsr", so it can be a program name with args.+set dummy mktexlsr; ac_word=$2+{ echo "$as_me:$LINENO: checking for $ac_word" >&5+echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; }+if test "${ac_cv_path_MKTEXLSR+set}" = set; then+  echo $ECHO_N "(cached) $ECHO_C" >&6+else+  case $MKTEXLSR in+  [\\/]* | ?:[\\/]*)+  ac_cv_path_MKTEXLSR="$MKTEXLSR" # Let the user override the test with a path.+  ;;+  *)+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  for ac_exec_ext in '' $ac_executable_extensions; do+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then+    ac_cv_path_MKTEXLSR="$as_dir/$ac_word$ac_exec_ext"+    echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5+    break 2+  fi+done+done+IFS=$as_save_IFS++  ;;+esac+fi+MKTEXLSR=$ac_cv_path_MKTEXLSR+if test -n "$MKTEXLSR"; then+  { echo "$as_me:$LINENO: result: $MKTEXLSR" >&5+echo "${ECHO_T}$MKTEXLSR" >&6; }+else+  { echo "$as_me:$LINENO: result: no" >&5+echo "${ECHO_T}no" >&6; }+fi++++# docdir and expansion+docdir="$datadir/doc/$PACKAGE_TARNAME-$PACKAGE_VERSION"+++# lhs2TeX binary path relative to docdir+LHS2TEX="../lhs2TeX"+++ac_config_files="$ac_config_files config.mk Version.lhs lhs2TeX.1 doc/InteractiveHugs.lhs doc/InteractivePre.lhs"++cat >confcache <<\_ACEOF+# This file is a shell script that caches the results of configure+# tests run on this system so they can be shared between configure+# scripts and configure runs, see configure's option --config-cache.+# It is not useful on other systems.  If it contains results you don't+# want to keep, you may remove or edit it.+#+# config.status only pays attention to the cache file if you give it+# the --recheck option to rerun configure.+#+# `ac_cv_env_foo' variables (set or unset) will be overridden when+# loading this file, other *unset* `ac_cv_foo' will be assigned the+# following values.++_ACEOF++# The following way of writing the cache mishandles newlines in values,+# but we know of no workaround that is simple, portable, and efficient.+# So, we kill variables containing newlines.+# Ultrix sh set writes to stderr and can't be redirected directly,+# and sets the high bit in the cache file unless we assign to the vars.+(+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do+    eval ac_val=\$$ac_var+    case $ac_val in #(+    *${as_nl}*)+      case $ac_var in #(+      *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5+echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;;+      esac+      case $ac_var in #(+      _ | IFS | as_nl) ;; #(+      *) $as_unset $ac_var ;;+      esac ;;+    esac+  done++  (set) 2>&1 |+    case $as_nl`(ac_space=' '; set) 2>&1` in #(+    *${as_nl}ac_space=\ *)+      # `set' does not quote correctly, so add quotes (double-quote+      # substitution turns \\\\ into \\, and sed turns \\ into \).+      sed -n \+	"s/'/'\\\\''/g;+	  s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"+      ;; #(+    *)+      # `set' quotes correctly as required by POSIX, so do not add quotes.+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+      ;;+    esac |+    sort+) |+  sed '+     /^ac_cv_env_/b end+     t clear+     :clear+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/+     t end+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/+     :end' >>confcache+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else+  if test -w "$cache_file"; then+    test "x$cache_file" != "x/dev/null" &&+      { echo "$as_me:$LINENO: updating cache $cache_file" >&5+echo "$as_me: updating cache $cache_file" >&6;}+    cat confcache >$cache_file+  else+    { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5+echo "$as_me: not updating unwritable cache $cache_file" >&6;}+  fi+fi+rm -f confcache++test "x$prefix" = xNONE && prefix=$ac_default_prefix+# Let make expand exec_prefix.+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'++# Transform confdefs.h into DEFS.+# Protect against shell expansion while executing Makefile rules.+# Protect against Makefile macro expansion.+#+# If the first sed substitution is executed (which looks for macros that+# take arguments), then branch to the quote section.  Otherwise,+# look for a macro that doesn't take arguments.+ac_script='+t clear+:clear+s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 (][^	 (]*([^)]*)\)[	 ]*\(.*\)/-D\1=\2/g+t quote+s/^[	 ]*#[	 ]*define[	 ][	 ]*\([^	 ][^	 ]*\)[	 ]*\(.*\)/-D\1=\2/g+t quote+b any+:quote+s/[	 `~#$^&*(){}\\|;'\''"<>?]/\\&/g+s/\[/\\&/g+s/\]/\\&/g+s/\$/$$/g+H+:any+${+	g+	s/^\n//+	s/\n/ /g+	p+}+'+DEFS=`sed -n "$ac_script" confdefs.h`+++ac_libobjs=+ac_ltlibobjs=+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue+  # 1. Remove the extension, and $U if already installed.+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'+  ac_i=`echo "$ac_i" | sed "$ac_script"`+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR+  #    will be set to the directory where LIBOBJS objects are built.+  ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext"+  ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo'+done+LIBOBJS=$ac_libobjs++LTLIBOBJS=$ac_ltlibobjs++++: ${CONFIG_STATUS=./config.status}+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files $CONFIG_STATUS"+{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5+echo "$as_me: creating $CONFIG_STATUS" >&6;}+cat >$CONFIG_STATUS <<_ACEOF+#! $SHELL+# Generated by $as_me.+# Run this file to recreate the current configuration.+# Compiler output produced by configure, useful for debugging+# configure, is in config.log if it exists.++debug=false+ac_cs_recheck=false+ac_cs_silent=false+SHELL=\${CONFIG_SHELL-$SHELL}+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF+## --------------------- ##+## M4sh Initialization.  ##+## --------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then+  emulate sh+  NULLCMD=:+  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which+  # is contrary to our usage.  Disable this feature.+  alias -g '${1+"$@"}'='"$@"'+  setopt NO_GLOB_SUBST+else+  case `(set -o) 2>/dev/null` in+  *posix*) set -o posix ;;+esac++fi+++++# PATH needs CR+# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits++# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+  echo "#! /bin/sh" >conf$$.sh+  echo  "exit 0"   >>conf$$.sh+  chmod +x conf$$.sh+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then+    PATH_SEPARATOR=';'+  else+    PATH_SEPARATOR=:+  fi+  rm -f conf$$.sh+fi++# Support unset when possible.+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then+  as_unset=unset+else+  as_unset=false+fi+++# IFS+# We need space, tab and new line, in precisely that order.  Quoting is+# there to prevent editors from complaining about space-tab.+# (If _AS_PATH_WALK were called with IFS unset, it would disable word+# splitting by setting IFS to empty value.)+as_nl='+'+IFS=" ""	$as_nl"++# Find who we are.  Look in the path if we contain no directory separator.+case $0 in+  *[\\/]* ) as_myself=$0 ;;+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break+done+IFS=$as_save_IFS++     ;;+esac+# We did not find ourselves, most probably we were run as `sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+  as_myself=$0+fi+if test ! -f "$as_myself"; then+  echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+  { (exit 1); exit 1; }+fi++# Work around bugs in pre-3.0 UWIN ksh.+for as_var in ENV MAIL MAILPATH+do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var+done+PS1='$ '+PS2='> '+PS4='+ '++# NLS nuisances.+for as_var in \+  LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \+  LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \+  LC_TELEPHONE LC_TIME+do+  if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then+    eval $as_var=C; export $as_var+  else+    ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var+  fi+done++# Required to use basename.+if expr a : '\(a\)' >/dev/null 2>&1 &&+   test "X`expr 00001 : '.*\(...\)'`" = X001; then+  as_expr=expr+else+  as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+  as_basename=basename+else+  as_basename=false+fi+++# Name of the executable.+as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+	 X"$0" : 'X\(//\)$' \| \+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||+echo X/"$0" |+    sed '/^.*\/\([^/][^/]*\)\/*$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`++# CDPATH.+$as_unset CDPATH++++  as_lineno_1=$LINENO+  as_lineno_2=$LINENO+  test "x$as_lineno_1" != "x$as_lineno_2" &&+  test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || {++  # Create $as_me.lineno as a copy of $as_myself, but with $LINENO+  # uniformly replaced by the line number.  The first 'sed' inserts a+  # line-number line after each line using $LINENO; the second 'sed'+  # does the real work.  The second script uses 'N' to pair each+  # line-number line with the line containing $LINENO, and appends+  # trailing '-' during substitution so that $LINENO is not a special+  # case at line end.+  # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the+  # scripts with optimization help from Paolo Bonzini.  Blame Lee+  # E. McMahon (1931-1989) for sed's syntax.  :-)+  sed -n '+    p+    /[$]LINENO/=+  ' <$as_myself |+    sed '+      s/[$]LINENO.*/&-/+      t lineno+      b+      :lineno+      N+      :loop+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/+      t loop+      s/-\n.*//+    ' >$as_me.lineno &&+  chmod +x "$as_me.lineno" ||+    { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2+   { (exit 1); exit 1; }; }++  # Don't try to exec as it changes $[0], causing all sort of problems+  # (the dirname of $[0] is not the place where we might find the+  # original and so on.  Autoconf is especially sensitive to this).+  . "./$as_me.lineno"+  # Exit status is that of the last command.+  exit+}+++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+  as_dirname=dirname+else+  as_dirname=false+fi++ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in+-n*)+  case `echo 'x\c'` in+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.+  *)   ECHO_C='\c';;+  esac;;+*)+  ECHO_N='-n';;+esac++if expr a : '\(a\)' >/dev/null 2>&1 &&+   test "X`expr 00001 : '.*\(...\)'`" = X001; then+  as_expr=expr+else+  as_expr=false+fi++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+  rm -f conf$$.dir/conf$$.file+else+  rm -f conf$$.dir+  mkdir conf$$.dir+fi+echo >conf$$.file+if ln -s conf$$.file conf$$ 2>/dev/null; then+  as_ln_s='ln -s'+  # ... but there are two gotchas:+  # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.+  # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.+  # In both cases, we have to default to `cp -p'.+  ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+    as_ln_s='cp -p'+elif ln conf$$.file conf$$ 2>/dev/null; then+  as_ln_s=ln+else+  as_ln_s='cp -p'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null++if mkdir -p . 2>/dev/null; then+  as_mkdir_p=:+else+  test -d ./-p && rmdir ./-p+  as_mkdir_p=false+fi++if test -x / >/dev/null 2>&1; then+  as_test_x='test -x'+else+  if ls -dL / >/dev/null 2>&1; then+    as_ls_L_option=L+  else+    as_ls_L_option=+  fi+  as_test_x='+    eval sh -c '\''+      if test -d "$1"; then+        test -d "$1/.";+      else+	case $1 in+        -*)set "./$1";;+	esac;+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in+	???[sx]*):;;*)false;;esac;fi+    '\'' sh+  '+fi+as_executable_p=$as_test_x++# Sed expression to map a string onto a valid CPP name.+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"++# Sed expression to map a string onto a valid variable name.+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"+++exec 6>&1++# Save the log message, to keep $[0] and so on meaningful, and to+# report actual input values of CONFIG_FILES etc. instead of their+# values after options handling.+ac_log="+This file was extended by lhs2tex $as_me 1.12, which was+generated by GNU Autoconf 2.61.  Invocation command line was++  CONFIG_FILES    = $CONFIG_FILES+  CONFIG_HEADERS  = $CONFIG_HEADERS+  CONFIG_LINKS    = $CONFIG_LINKS+  CONFIG_COMMANDS = $CONFIG_COMMANDS+  $ $0 $@++on `(hostname || uname -n) 2>/dev/null | sed 1q`+"++_ACEOF++cat >>$CONFIG_STATUS <<_ACEOF+# Files that config.status was made for.+config_files="$ac_config_files"++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF+ac_cs_usage="\+\`$as_me' instantiates files from templates according to the+current configuration.++Usage: $0 [OPTIONS] [FILE]...++  -h, --help       print this help, then exit+  -V, --version    print version number and configuration settings, then exit+  -q, --quiet      do not print progress messages+  -d, --debug      don't remove temporary files+      --recheck    update $as_me by reconfiguring in the same conditions+  --file=FILE[:TEMPLATE]+		   instantiate the configuration file FILE++Configuration files:+$config_files++Report bugs to <bug-autoconf@gnu.org>."++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF+ac_cs_version="\\+lhs2tex config.status 1.12+configured by $0, generated by GNU Autoconf 2.61,+  with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"++Copyright (C) 2006 Free Software Foundation, Inc.+This config.status script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it."++ac_pwd='$ac_pwd'+srcdir='$srcdir'+INSTALL='$INSTALL'+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF+# If no file are specified by the user, then we need to provide default+# value.  By we need to know if files were specified by the user.+ac_need_defaults=:+while test $# != 0+do+  case $1 in+  --*=*)+    ac_option=`expr "X$1" : 'X\([^=]*\)='`+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`+    ac_shift=:+    ;;+  *)+    ac_option=$1+    ac_optarg=$2+    ac_shift=shift+    ;;+  esac++  case $ac_option in+  # Handling of the options.+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)+    ac_cs_recheck=: ;;+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )+    echo "$ac_cs_version"; exit ;;+  --debug | --debu | --deb | --de | --d | -d )+    debug=: ;;+  --file | --fil | --fi | --f )+    $ac_shift+    CONFIG_FILES="$CONFIG_FILES $ac_optarg"+    ac_need_defaults=false;;+  --he | --h |  --help | --hel | -h )+    echo "$ac_cs_usage"; exit ;;+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \+  | -silent | --silent | --silen | --sile | --sil | --si | --s)+    ac_cs_silent=: ;;++  # This is an error.+  -*) { echo "$as_me: error: unrecognized option: $1+Try \`$0 --help' for more information." >&2+   { (exit 1); exit 1; }; } ;;++  *) ac_config_targets="$ac_config_targets $1"+     ac_need_defaults=false ;;++  esac+  shift+done++ac_configure_extra_args=++if $ac_cs_silent; then+  exec 6>/dev/null+  ac_configure_extra_args="$ac_configure_extra_args --silent"+fi++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF+if \$ac_cs_recheck; then+  echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6+  CONFIG_SHELL=$SHELL+  export CONFIG_SHELL+  exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion+fi++_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF+exec 5>>config.log+{+  echo+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX+## Running $as_me. ##+_ASBOX+  echo "$ac_log"+} >&5++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF++# Handling of arguments.+for ac_config_target in $ac_config_targets+do+  case $ac_config_target in+    "config.mk") CONFIG_FILES="$CONFIG_FILES config.mk" ;;+    "Version.lhs") CONFIG_FILES="$CONFIG_FILES Version.lhs" ;;+    "lhs2TeX.1") CONFIG_FILES="$CONFIG_FILES lhs2TeX.1" ;;+    "doc/InteractiveHugs.lhs") CONFIG_FILES="$CONFIG_FILES doc/InteractiveHugs.lhs" ;;+    "doc/InteractivePre.lhs") CONFIG_FILES="$CONFIG_FILES doc/InteractivePre.lhs" ;;++  *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5+echo "$as_me: error: invalid argument: $ac_config_target" >&2;}+   { (exit 1); exit 1; }; };;+  esac+done+++# If the user did not use the arguments to specify the items to instantiate,+# then the envvar interface is used.  Set only those that are not.+# We use the long form for the default assignment because of an extremely+# bizarre bug on SunOS 4.1.3.+if $ac_need_defaults; then+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files+fi++# Have a temporary directory for convenience.  Make it in the build tree+# simply because there is no reason against having it here, and in addition,+# creating and moving files from /tmp can sometimes cause problems.+# Hook for its removal unless debugging.+# Note that there is a small window in which the directory will not be cleaned:+# after its creation but before its name has been assigned to `$tmp'.+$debug ||+{+  tmp=+  trap 'exit_status=$?+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status+' 0+  trap '{ (exit 1); exit 1; }' 1 2 13 15+}+# Create a (secure) tmp directory for tmp files.++{+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&+  test -n "$tmp" && test -d "$tmp"+}  ||+{+  tmp=./conf$$-$RANDOM+  (umask 077 && mkdir "$tmp")+} ||+{+   echo "$me: cannot create a temporary directory in ." >&2+   { (exit 1); exit 1; }+}++#+# Set up the sed scripts for CONFIG_FILES section.+#++# No need to generate the scripts if there are no CONFIG_FILES.+# This happens for instance when ./config.status config.h+if test -n "$CONFIG_FILES"; then++_ACEOF++++ac_delim='%!_!# '+for ac_last_try in false false false false false :; do+  cat >conf$$subs.sed <<_ACEOF+SHELL!$SHELL$ac_delim+PATH_SEPARATOR!$PATH_SEPARATOR$ac_delim+PACKAGE_NAME!$PACKAGE_NAME$ac_delim+PACKAGE_TARNAME!$PACKAGE_TARNAME$ac_delim+PACKAGE_VERSION!$PACKAGE_VERSION$ac_delim+PACKAGE_STRING!$PACKAGE_STRING$ac_delim+PACKAGE_BUGREPORT!$PACKAGE_BUGREPORT$ac_delim+exec_prefix!$exec_prefix$ac_delim+prefix!$prefix$ac_delim+program_transform_name!$program_transform_name$ac_delim+bindir!$bindir$ac_delim+sbindir!$sbindir$ac_delim+libexecdir!$libexecdir$ac_delim+datarootdir!$datarootdir$ac_delim+datadir!$datadir$ac_delim+sysconfdir!$sysconfdir$ac_delim+sharedstatedir!$sharedstatedir$ac_delim+localstatedir!$localstatedir$ac_delim+includedir!$includedir$ac_delim+oldincludedir!$oldincludedir$ac_delim+docdir!$docdir$ac_delim+infodir!$infodir$ac_delim+htmldir!$htmldir$ac_delim+dvidir!$dvidir$ac_delim+pdfdir!$pdfdir$ac_delim+psdir!$psdir$ac_delim+libdir!$libdir$ac_delim+localedir!$localedir$ac_delim+mandir!$mandir$ac_delim+DEFS!$DEFS$ac_delim+ECHO_C!$ECHO_C$ac_delim+ECHO_N!$ECHO_N$ac_delim+ECHO_T!$ECHO_T$ac_delim+LIBS!$LIBS$ac_delim+build_alias!$build_alias$ac_delim+host_alias!$host_alias$ac_delim+target_alias!$target_alias$ac_delim+VERSION!$VERSION$ac_delim+SHORTVERSION!$SHORTVERSION$ac_delim+NUMVERSION!$NUMVERSION$ac_delim+PRE!$PRE$ac_delim+GHC!$GHC$ac_delim+HUGS!$HUGS$ac_delim+INSTALL_PROGRAM!$INSTALL_PROGRAM$ac_delim+INSTALL_SCRIPT!$INSTALL_SCRIPT$ac_delim+INSTALL_DATA!$INSTALL_DATA$ac_delim+LN_S!$LN_S$ac_delim+MV!$MV$ac_delim+CP!$CP$ac_delim+RM!$RM$ac_delim+MKDIR!$MKDIR$ac_delim+TOUCH!$TOUCH$ac_delim+DIFF!$DIFF$ac_delim+GREP!$GREP$ac_delim+SED!$SED$ac_delim+SORT!$SORT$ac_delim+UNIQ!$UNIQ$ac_delim+FIND!$FIND$ac_delim+LATEX!$LATEX$ac_delim+PDFLATEX!$PDFLATEX$ac_delim+XDVI!$XDVI$ac_delim+GV!$GV$ac_delim+DVIPS!$DVIPS$ac_delim+KPSEWHICH!$KPSEWHICH$ac_delim+texmf!$texmf$ac_delim+POLYTABLE_INSTALL!$POLYTABLE_INSTALL$ac_delim+MKTEXLSR!$MKTEXLSR$ac_delim+LHS2TEX!$LHS2TEX$ac_delim+LIBOBJS!$LIBOBJS$ac_delim+LTLIBOBJS!$LTLIBOBJS$ac_delim+_ACEOF++  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 70; then+    break+  elif $ac_last_try; then+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}+   { (exit 1); exit 1; }; }+  else+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "+  fi+done++ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`+if test -n "$ac_eof"; then+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`+  ac_eof=`expr $ac_eof + 1`+fi++cat >>$CONFIG_STATUS <<_ACEOF+cat >"\$tmp/subs-1.sed" <<\CEOF$ac_eof+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end+_ACEOF+sed '+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g+s/^/s,@/; s/!/@,|#_!!_#|/+:n+t n+s/'"$ac_delim"'$/,g/; t+s/$/\\/; p+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n+' >>$CONFIG_STATUS <conf$$subs.sed+rm -f conf$$subs.sed+cat >>$CONFIG_STATUS <<_ACEOF+:end+s/|#_!!_#|//g+CEOF$ac_eof+_ACEOF+++# VPATH may cause trouble with some makes, so we remove $(srcdir),+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and+# trailing colons and then remove the whole line if VPATH becomes empty+# (actually we leave an empty line to preserve line numbers).+if test "x$srcdir" = x.; then+  ac_vpsub='/^[	 ]*VPATH[	 ]*=/{+s/:*\$(srcdir):*/:/+s/:*\${srcdir}:*/:/+s/:*@srcdir@:*/:/+s/^\([^=]*=[	 ]*\):*/\1/+s/:*$//+s/^[^=]*=[	 ]*$//+}'+fi++cat >>$CONFIG_STATUS <<\_ACEOF+fi # test -n "$CONFIG_FILES"+++for ac_tag in  :F $CONFIG_FILES+do+  case $ac_tag in+  :[FHLC]) ac_mode=$ac_tag; continue;;+  esac+  case $ac_mode$ac_tag in+  :[FHL]*:*);;+  :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5+echo "$as_me: error: Invalid tag $ac_tag." >&2;}+   { (exit 1); exit 1; }; };;+  :[FH]-) ac_tag=-:-;;+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;+  esac+  ac_save_IFS=$IFS+  IFS=:+  set x $ac_tag+  IFS=$ac_save_IFS+  shift+  ac_file=$1+  shift++  case $ac_mode in+  :L) ac_source=$1;;+  :[FH])+    ac_file_inputs=+    for ac_f+    do+      case $ac_f in+      -) ac_f="$tmp/stdin";;+      *) # Look for the file first in the build tree, then in the source tree+	 # (if the path is not absolute).  The absolute path cannot be DOS-style,+	 # because $ac_f cannot contain `:'.+	 test -f "$ac_f" ||+	   case $ac_f in+	   [\\/$]*) false;;+	   *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;+	   esac ||+	   { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5+echo "$as_me: error: cannot find input file: $ac_f" >&2;}+   { (exit 1); exit 1; }; };;+      esac+      ac_file_inputs="$ac_file_inputs $ac_f"+    done++    # Let's still pretend it is `configure' which instantiates (i.e., don't+    # use $as_me), people would be surprised to read:+    #    /* config.h.  Generated by config.status.  */+    configure_input="Generated from "`IFS=:+	  echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure."+    if test x"$ac_file" != x-; then+      configure_input="$ac_file.  $configure_input"+      { echo "$as_me:$LINENO: creating $ac_file" >&5+echo "$as_me: creating $ac_file" >&6;}+    fi++    case $ac_tag in+    *:-:* | *:-) cat >"$tmp/stdin";;+    esac+    ;;+  esac++  ac_dir=`$as_dirname -- "$ac_file" ||+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+	 X"$ac_file" : 'X\(//\)[^/]' \| \+	 X"$ac_file" : 'X\(//\)$' \| \+	 X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||+echo X"$ac_file" |+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)[^/].*/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`+  { as_dir="$ac_dir"+  case $as_dir in #(+  -*) as_dir=./$as_dir;;+  esac+  test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || {+    as_dirs=+    while :; do+      case $as_dir in #(+      *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #(+      *) as_qdir=$as_dir;;+      esac+      as_dirs="'$as_qdir' $as_dirs"+      as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+	 X"$as_dir" : 'X\(//\)[^/]' \| \+	 X"$as_dir" : 'X\(//\)$' \| \+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+echo X"$as_dir" |+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)[^/].*/{+	    s//\1/+	    q+	  }+	  /^X\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`+      test -d "$as_dir" && break+    done+    test -z "$as_dirs" || eval "mkdir $as_dirs"+  } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5+echo "$as_me: error: cannot create directory $as_dir" >&2;}+   { (exit 1); exit 1; }; }; }+  ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+  ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'`+  # A ".." for each directory in $ac_dir_suffix.+  ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'`+  case $ac_top_builddir_sub in+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;+  esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+  .)  # We are building in place.+    ac_srcdir=.+    ac_top_srcdir=$ac_top_builddir_sub+    ac_abs_top_srcdir=$ac_pwd ;;+  [\\/]* | ?:[\\/]* )  # Absolute name.+    ac_srcdir=$srcdir$ac_dir_suffix;+    ac_top_srcdir=$srcdir+    ac_abs_top_srcdir=$srcdir ;;+  *) # Relative name.+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+    ac_top_srcdir=$ac_top_build_prefix$srcdir+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix+++  case $ac_mode in+  :F)+  #+  # CONFIG_FILE+  #++  case $INSTALL in+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;+  esac+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF+# If the template does not know about datarootdir, expand it.+# FIXME: This hack should be removed a few years after 2.60.+ac_datarootdir_hack=; ac_datarootdir_seen=++case `sed -n '/datarootdir/ {+  p+  q+}+/@datadir@/p+/@docdir@/p+/@infodir@/p+/@localedir@/p+/@mandir@/p+' $ac_file_inputs` in+*datarootdir*) ac_datarootdir_seen=yes;;+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)+  { echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5+echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}+_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF+  ac_datarootdir_hack='+  s&@datadir@&$datadir&g+  s&@docdir@&$docdir&g+  s&@infodir@&$infodir&g+  s&@localedir@&$localedir&g+  s&@mandir@&$mandir&g+    s&\\\${datarootdir}&$datarootdir&g' ;;+esac+_ACEOF++# Neutralize VPATH when `$srcdir' = `.'.+# Shell code in configure.ac might set extrasub.+# FIXME: do we really want to maintain this feature?+cat >>$CONFIG_STATUS <<_ACEOF+  sed "$ac_vpsub+$extrasub+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF+:t+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b+s&@configure_input@&$configure_input&;t t+s&@top_builddir@&$ac_top_builddir_sub&;t t+s&@srcdir@&$ac_srcdir&;t t+s&@abs_srcdir@&$ac_abs_srcdir&;t t+s&@top_srcdir@&$ac_top_srcdir&;t t+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t+s&@builddir@&$ac_builddir&;t t+s&@abs_builddir@&$ac_abs_builddir&;t t+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t+s&@INSTALL@&$ac_INSTALL&;t t+$ac_datarootdir_hack+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" >$tmp/out++test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&+  { echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir'+which seems to be undefined.  Please make sure it is defined." >&5+echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'+which seems to be undefined.  Please make sure it is defined." >&2;}++  rm -f "$tmp/stdin"+  case $ac_file in+  -) cat "$tmp/out"; rm -f "$tmp/out";;+  *) rm -f "$ac_file"; mv "$tmp/out" $ac_file;;+  esac+ ;;++++  esac++done # for ac_tag+++{ (exit 0); exit 0; }+_ACEOF+chmod +x $CONFIG_STATUS+ac_clean_files=$ac_clean_files_save+++# configure is writing to config.log, and then calls config.status.+# config.status does its own redirection, appending to config.log.+# Unfortunately, on DOS this fails, as config.log is still kept open+# by configure, so config.status won't be able to write to it; its+# output is simply discarded.  So we exec the FD to /dev/null,+# effectively closing config.log, so it can be properly (re)opened and+# appended to by config.status.  When coming back to configure, we+# need to make the FD available again.+if test "$no_create" != yes; then+  ac_cs_success=:+  ac_config_status_args=+  test "$silent" = yes &&+    ac_config_status_args="$ac_config_status_args --quiet"+  exec 5>/dev/null+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false+  exec 5>>config.log+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which+  # would make configure fail if this is the last instruction.+  $ac_cs_success || { (exit 1); exit 1; }+fi+++echo "Configuration succesfully completed."+echo "Say"+echo "     make               to compile and build documentation"+echo "     make bin           to compile the binary only"+echo "     make install       to (compile and) install"+
+ doc/AGExample.lhs view
@@ -0,0 +1,22 @@+%include poly.fmt+%format ^  = " "+%format ^^ = "\;"+%format ATTR = "\mathbf{ATTR}"+%format SEM  = "\mathbf{SEM}"+%format lhs  = "\mathbf{lhs}"+%format .  = "."+%format *  = "\times"+%format (A(n)(f)) = @ n . f+\begin{code}+ATTR Expr Factor   [ ^^ | ^^ | numvars   : Int  ]+ATTR Expr Factor   [ ^^ | ^^ | value     : Int  ]++SEM Expr+  |  Sum       +              lhs   .  value     =  A left value    +  A right value+                    .  numvars   =  A left numvars  +  A right numvars+SEM Factor+  |  Prod      +              lhs   .  value     =  A left value    *  A right value+                    .  numvars   =  A left numvars  +  A right numvars+\end{code}
+ doc/AGExampleIn.lhs view
@@ -0,0 +1,31 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+%if stc+\let\small\scriptsize+%endif+\def\tt#1#2{\origtt\makebox[0pt]{\phantom{X}}}++>%format ^  = " "+>%format ^^ = "\;"+>%format ATTR = "\mathbf{ATTR}"+>%format SEM  = "\mathbf{SEM}"+>%format lhs  = "\mathbf{lhs}"+>%format .  = "."+>%format *  = "\times"+>%format (A(n)(f)) = @ n . f+>\begin{code}+>ATTR Expr Factor  [ ^^ | ^^ | numvars   : Int  ]+>ATTR Expr Factor  [ ^^ | ^^ | value     : Int  ]+>+>SEM Expr+>  |  Sum       +>              lhs   .  value     =  A left value    +  A right value+>                    .  numvars   =  A left numvars  +  A right numvars+>SEM Factor+>  |  Prod      +>              lhs   .  value     =  A left value    *  A right value+>                    .  numvars   =  A left numvars  +  A right numvars+>\end{code}++\endgroup
+ doc/Accidental.lhs view
@@ -0,0 +1,11 @@+%include poly.fmt++%format <| = "\lhd "++> options  ::  [String] -> ([Class],[String])+> options  =   foldr (<|) ([],[])+>   where  "-align"     <| (ds,s:  as) = (Dir Align    s :  ds,     as)+>          ('-':'i':s)  <| (ds,    as) = (Dir Include  s :  ds,     as)+>          ('-':'l':s)  <| (ds,    as) = (Dir Let      s :  ds,     as)+>          s            <| (ds,    as) = (                  ds,s :  as)+
+ doc/AccidentalC.lhs view
@@ -0,0 +1,11 @@+%include poly.fmt++%format <| = "\lhd "++> options  ::  [String] -> ([Class],[String])+> options  =   foldr (<|) ([],[])+>   where   "-align"     <| (ds,s:  as) = (Dir Align    s :  ds,     as)+>           ('-':'i':s)  <| (ds,    as) = (Dir Include  s :  ds,     as)+>           ('-':'l':s)  <| (ds,    as) = (Dir Let      s :  ds,     as)+>           s            <| (ds,    as) = (                  ds,s :  as)+
+ doc/AccidentalCIn.lhs view
@@ -0,0 +1,25 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" +%format \ = "\char''134"+%format let = "let"+%format in  = "in"+%format where = "where"+%format ->  = "->"+%format !=  = "{\origcolor{hcolor}" = "}"+%format !:: = "{\origcolor{hcolor}" :: "}"+%format ^ = " "+%format C = "{\origcolor{hcolor}"+%format D = "}"+\begingroup+\let\origtt=\texfamily+\let\small\footnotesize+\def\texfamily#1{\origtt}+>%format <| = "\lhd "+>+>> options  !::  [String] -> ([Class],[String])+>> options  !=   foldr (<|) ([],[])+>>   where   C^"-align"^D     <| (ds,s:  as) = (Dir Align    s :  ds,     as)+>>           C^('-':'i':s)^D <| (ds,    as) = (Dir Include  s :  ds,     as)+>>           C^('-':'l':s)^D <| (ds,    as) = (Dir Let      s :  ds,     as)+>>           C^s^D           <| (ds,    as) = (                  ds,s :  as)+\endgroup
+ doc/AccidentalIn.lhs view
@@ -0,0 +1,25 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" +%format \ = "\char''134"+%format let = "let"+%format in  = "in"+%format where = "where"+%format ->  = "->"+%format !=  = "{\origcolor{hcolor}" = "}"+%format !:: = "{\origcolor{hcolor}" :: "}"+%format ^ = " "+%format C = "{\origcolor{hcolor}"+%format D = "}"+\begingroup+\let\origtt=\texfamily+\let\small\footnotesize+\def\texfamily#1{\origtt}+>%format <| = "\lhd "+>+>> options  !::  [String] -> ([Class],[String])+>> options  !=   foldr (<|) ([],[])+>>   where  C^"-align"^D     <| (ds,s:  as) = (Dir Align    s :  ds,     as)+>>          C^('-':'i':s)^D <| (ds,    as) = (Dir Include  s :  ds,     as)+>>          C^('-':'l':s)^D <| (ds,    as) = (Dir Let      s :  ds,     as)+>>          C^s^D           <| (ds,    as) = (                  ds,s :  as)+\endgroup
+ doc/AlignColumnSyntax.lhs view
@@ -0,0 +1,43 @@+%include tex.fmt+\newcommand*{\bslash}{@\@}+\newcommand*{\atsym}{\texttt{\char64}}+%format \ = "\bslash "+%format @ = "\atsym "+%format @@ = @ @+%format > = "\texttt{>}"+%format < = "\texttt{<}"+%format columnspec = "\Varid{column\text{\itshape -}specifier}"++\invisiblecomments+\begin{code}+term(\aligncolumn){ent(integer)}{ent(columnspec)}+\end{code}+The |ent(integer)| denotes the number (i.e.~as displayed by the+editor) of a column. Note that @lhs2TeX@ starts counting columns at 1.+As |ent(columnspec)| one can use about the same strings that one+can use to format a column in a @tabular@ environment using the+\LaTeX\ @array@~\cite{array} package. Table~\ref{columnspec} has a short +(and not necessarily complete) overview.+\begin{table}+\centering+\begin{colorsurround}+\begin{tabularx}{\linewidth}{cX}+@l@ & left-align column \\+@c@ & center column \\+@r@ & right-align column \\+|term(p){ent(dimen)}| & make column of fixed width |ent(dimen)| \\+|@@{ent(tex)}| & can be used before or after the letter specifying+                 alignment to suppress inter-column space and typeset+                 |ent(tex)| instead; note that this is usually achieved+                 using just one \texttt{\atsym}, but as @lhs2TeX@ +                 interprets the \texttt{\atsym}, it must be escaped \\+|>{ent(tex)}| & can be used before the letter specifying the alignment+              to insert |ent(tex)| directly in front of the entry+              of the column \\+|<{ent(tex)}| & can be used after the letter specifying the alignment+              to insert |ent(tex)| directly after the entry of the+              column+\end{tabularx}+\end{colorsurround}+\caption{Column specifiers for @\aligncolumn@}\label{columnspec}+\end{table}
+ doc/CabalInstallation.lhs view
@@ -0,0 +1,12 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" ++\begingroup+\let\origtt=\texfamily+\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+\begin{code}+$ runghc Setup configure+$ runghc Setup build+$ runghc Setup install+\end{code}+\endgroup
+ doc/CalcExample.lhs view
@@ -0,0 +1,26 @@+%include poly.fmt+\def\commentbegin{\quad\{\ }+\def\commentend{\}}+\begin{spec}+    map (+1) [1,2,3]++==  {- desugaring of |(:)| -}++    map (+1) (1 : [2,3])++==  {- definition of |map| -}++    (+1) 1  :  map (+1) [2,3]++==  {- performing the addition on the head -}++    2       :  map (+1) [2,3]++==  {- recursive application of |map| -}++    2       :  [3,4]++==  {- list syntactic sugar -}++    [2,3,4]+\end{spec}
+ doc/CalcExampleIn.lhs view
@@ -0,0 +1,35 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+%if stc+\let\small\scriptsize+%endif+\def\tt#1#2{\origtt\makebox[0pt]{\phantom{X}}}++>\def\commentbegin{\quad\{\ }+>\def\commentend{\}}+>\begin{spec}+>    map (+1) [1,2,3]+>+>==  {- desugaring of |(:)| -}+>+>    map (+1) (1 : [2,3])+>+>==  {- definition of |map| -}+>+>    (+1) 1  :  map (+1) [2,3]+>+>==  {- performing the addition on the head -}+>+>    2       :  map (+1) [2,3]+>+>==  {- recursive application of |map| -}+>+>    2       :  [3,4]+>+>==  {- list syntactic sugar -}+>+>    [2,3,4]+>\end{spec}++\endgroup
+ doc/Card.lhs view
@@ -0,0 +1,9 @@+%include poly.fmt++%format abs (a) = "\mathopen{|}" a "\mathclose{|}"+%format ~>      = "\leadsto"++The |abs| function computes the absolute value of an integer:+\begin{code}+abs(-2) ~> 2+\end{code}
+ doc/CardIn.lhs view
@@ -0,0 +1,12 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>%format abs (a) = "\mathopen{|}" a "\mathclose{|}"+>%format ~>      = "\leadsto"+>The |abs| function computes the absolute value of +>an integer:+>\begin{code}+>abs(-2) ~> 2+>\end{code}+\endgroup
+ doc/CompleteDirectives.lhs view
@@ -0,0 +1,22 @@+%include tex.fmt++\begingroup+\invisiblecomments+\begin{code}+dir(include)              -- include a file+dir(format)               -- formatting directive for an identifer/operator+dir({)                    -- begin of an @lhs2TeX@ group+dir(})                    -- end of an @lhs2TeX@ group+dir(^let^)                -- set a toggle+dir(^if^)                 -- test a condition+dir(^else^)               -- second part of conditional+dir(elif)                 -- @else@ combined with @if@+dir(endif)                -- end of a conditional+dir(latency)              -- tweak alignment in \textbf{poly} mode+dir(separation)     ^^^   -- tweak alignment in \textbf{poly} mode+dir(align)                -- set alignment column in \textbf{math} mode+dir(options)              -- set options for call of external program+dir(subst)                -- primitive formatting directive+dir(file)                 -- set filename+\end{code}+\endgroup
+ doc/ConfigureCall.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+$ ./configure --prefix=/my/local/programs+\end{code}+\endgroup
+ doc/FormatArrow.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format ~> = "\leadsto "++\endgroup
+ doc/FormatArrow2.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format ~>* = ~> "^{" * "}"++\endgroup
+ doc/FormatElem.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format `elem`     = "\in "++\endgroup
+ doc/FormatGreekIn.lhs view
@@ -0,0 +1,12 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format alpha = "\alpha"+>+>\begin{code}+>tan alpha = sin alpha / cos alpha+>\end{code}++\endgroup
+ doc/FormatGreekOut.lhs view
@@ -0,0 +1,6 @@+%include poly.fmt+%format alpha = "\alpha"++\begin{code}+tan alpha = sin alpha / cos alpha+\end{code}
+ doc/FormatId.lhs view
@@ -0,0 +1,10 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format new      = "\mathbf{new}"+>%format text0    = text+>%format text_new = text "_{" new "}"++\endgroup
+ doc/FormatIdentifierExamples.lhs view
@@ -0,0 +1,10 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format ++         = "\plus "+>%format undefined  = "\bot "+>%format not        = "\neg "++\endgroup
+ doc/FormatIdentifierRedefs.lhs view
@@ -0,0 +1,10 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format ++         = "\mathbin{\mathbf{+}}"+>%format undefined  = "\Varid{undefined}"+>%format not        = "!"++\endgroup
+ doc/FormatIdentifierWrong.lhs view
@@ -0,0 +1,9 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%% THE FOLLOWING IS BAD:+>%format undefined  = "undefined"++\endgroup
+ doc/FormatRecurse.lhs view
@@ -0,0 +1,9 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%% THE FOLLOWING IS BAD:+>%format text = "\mathsf{" text "}"++\endgroup
+ doc/FormatStar.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>%format * = "\star "++\endgroup
+ doc/FormatSyntax.lhs view
@@ -0,0 +1,17 @@+%include tex.fmt+%format symorname = sym_or_name++\invisiblecomments+\begin{code}+dir(format) ^^ ent(token) = many(ent(fmttoken))     ^^^  -- (format single tokens)+dir(format) ^^ ent(lhs) = many(ent(fmttoken))            -- (parametrized formatting)+dir(format) ^^ ent(name)                                 -- (implicit formatting)++ent(lhs)        ::=  ent(name) ^^ many(ent(arg)) | (ent(name)) ^^ many(ent(arg))+ent(name)       ::=  ent(varname) | ent(conname)+ent(arg)        ::=  ent(varname) | (ent(varname))+ent(fmttoken)   ::=  string(ent(text)) | ent(token)+\end{code}+%old stuff:+%ent(lhs)        ::=  ent(symorname) ^^ many(ent(arg)) | (ent(symorname) ^^ many(ent(arg)))+%ent(symorname)  ::=  ent(name) | back(ent(name)) | (ent(operator))
+ doc/GHExample.lhs view
@@ -0,0 +1,40 @@+%include poly.fmt+%if style == "newcode"+%format ^+%format ^^    = " "+%format ti(a) = "{|" a "|}"+%format ki(a) = "{[" a "]}"+%else+%format ^     = " "+%format ^^    = "\;"+%format ti(a) = "\lty " a "\rty "+%format ki(a) = "\lki " a "\rki "+\newcommand{\lty}{\mathopen{\{\mskip-3.4mu||}}+\newcommand{\rty}{\mathclose{||\mskip-3.4mu\}}}+\newcommand{\lki}{\mathopen{\{\mskip-3.5mu[}}+\newcommand{\rki}{\mathclose{]\mskip-3.5mu\}}}+%format t1+%format t2+%format a1+%format a2+%format r_ = "\rho "+%format s_ = "\sigma "+%format k_ = "\kappa "+%format forall a = "\forall " a+%format . = "."+%format mapa = map "_{" a "}"+%format mapb = map "_{" b "}"+%format :*: = "\times "+%endif+\begin{code}+type Map^ki(*)         t1  t2       =   t1 -> t2+type Map^ki(r_ -> s_)  t1  t2       =   forall a1 a2. Map^ki(r_) a1 a2 +                                          -> Map^ki(s_) (t1 a1) (t2 a2)++map^ti(t :: k_)                     ::  Map^ki(k_) t t+map^ti(Unit)             Unit       =   Unit+map^ti(Int)              i          =   i+map^ti(Sum)   mapa mapb  (Inl  a)   =   Inl  (mapa a)+map^ti(Sum)   mapa mapb  (Inr  b)   =   Inr  (mapb b)+map^ti(Prod)  mapa mapb  (a :*: b)  =   mapa a :*: mapb b+\end{code}
+ doc/GHExampleIn.lhs view
@@ -0,0 +1,47 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\let\small\scriptsize+\def\tt#1#2{\origtt\makebox[0pt]{\phantom{X}}}++>%if style == newcode+>%format ^+>%format ^^    = " "+>%format ti(a) = "{|" a "|}"+>%format ki(a) = "{[" a "]}"+>%else+>%format ^     = " "+>%format ^^    = "\;"+>%format ti(a) = "\lty " a "\rty "+>%format ki(a) = "\lki " a "\rki "+>\newcommand{\lty}{\mathopen{\{\mskip-3.4mu||}}+>\newcommand{\rty}{\mathclose{||\mskip-3.4mu\}}}+>\newcommand{\lki}{\mathopen{\{\mskip-3.5mu[}}+>\newcommand{\rki}{\mathclose{]\mskip-3.5mu\}}}+>%format t1+>%format t2+>%format a1+>%format a2+>%format r_    = "\rho "+>%format s_    = "\sigma "+>%format k_    = "\kappa "+>%format forall a = "\forall " a+>%format .     = "."+>%format mapa  = map "_{" a "}"+>%format mapb  = map "_{" b "}"+>%format :*:   = "\times "+>%endif+>\begin{code}+>type Map^ki(*)         t1  t2       =   t1 -> t2+>type Map^ki(r_ -> s_)  t1  t2       =   forall a1 a2. Map^ki(r_) a1 a2 +>                                          -> Map^ki(s_) (t1 a1) (t2 a2)+>+>map^ti(t :: k_)                     ::  Map^ki(k_) t t+>map^ti(Unit)             Unit       =   Unit+>map^ti(Int)              i          =   i+>map^ti(Sum)   mapa mapb  (Inl  a)   =   Inl  (mapa a)+>map^ti(Sum)   mapa mapb  (Inr  b)   =   Inr  (mapb b)+>map^ti(Prod)  mapa mapb  (a :*: b)  =   mapa a :*: mapb b+>\end{code}++\endgroup
+ doc/GroupExample.lhs view
@@ -0,0 +1,10 @@+%include poly.fmt++In the beginning: |one|.\par+%format one = "\mathsf{1}"+Before the group: |one|.\par+%{+%format one = "\mathsf{one}"+Inside the group: |one|.\par+%}+After the group: |one|.
+ doc/GroupExampleIn.lhs view
@@ -0,0 +1,15 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+In the beginning: |one|.\par+%format one = "\mathsf{1}"+Before the group: |one|.\par+%{+%format one = "\mathsf{one}"+Inside the group: |one|.\par+%}+After the group: |one|.+\end{code}+\endgroup
+ doc/GroupSyntax.lhs view
@@ -0,0 +1,8 @@+%include tex.fmt+%format ... = "\dots "++\begin{code}+dir({)+...+dir(})+\end{code}
+ doc/Guide2.dontbuild view
+ doc/Guide2.lhs view
@@ -0,0 +1,1814 @@+\documentclass[10pt]{scrartcl}++% save linebreak; see below+\let\origlinebreak=\\++\renewcommand{\sectfont}{\bf}++%let framed = False++\usepackage[english]{babel}+%\usepackage[fleqn]{amsmath}+\usepackage{stmaryrd}++\usepackage{hyperref}++%\usepackage[T1]{fontenc}+\usepackage{mathpazo}+%\usepackage[scaled=0.9]{luximono}+\usepackage{colortbl}+\usepackage{calc}+%\usepackage{pifont}+\usepackage{paralist}+\usepackage{ifthen}+\usepackage{relsize}+\usepackage{xspace}+\usepackage{tabularx}+%if framed+\usepackage{framed}+\FrameSep=2\fboxsep+%endif++\newcommand*{\PDF}{{\smaller{PDF}}\xspace}+\newcommand*{\CTAN}{{\smaller{CTAN}}\xspace}+\setdefaultitem{\textbf{--}}{}{}{}++\let\defined\textbf++%let doc = True+%include lhs2TeX.fmt+%include Version.lhs++\newlength{\lwidth}+\newlength{\cwidth}+\setlength{\lwidth}{0pt}+\setlength{\cwidth}{0pt}++%separation 2+%latency 2++\let\origcolor=\color+\newcommand{\dep}[1]{{\origcolor{red}#1}}+\def\swgt#1{\switch[\value{step}>#1]}%+\def\ro#1{\ifthenelse{\value{step}=#1}{\origcolor{red}}{}}%++%\usepackage[display]{texpower}++%hyperref needs some setup, especially after pdfscreen+\hypersetup{%+  colorlinks=True,%+  pdfmenubar=True,%+  pdfcenterwindow=False,% +  pdffitwindow=False}%++%fixed lengths are better ... +% \AtBeginDocument{%+% \setlength{\abovedisplayskip}{6pt plus 0pt minus 0pt}% originally 10.0pt plus 2.0pt minus 5.0pt+% \setlength{\belowdisplayskip}{6pt plus 0pt minus 0pt}% originally 10.0pt plus 2.0pt minus 5.0pt+% }+% \setlength{\belowdisplayshortskip}{6pt plus 0pt minus 0pt}%+% \setlength{\abovedisplayshortskip}{6pt plus 0pt minus 0pt}%+% \setlength{\smallskipamount}{2pt}+% \setlength{\medskipamount}{5pt}+% \setlength{\bigskipamount}{10pt}+% +% +% \setlength\pltopsep{2pt}+% \setlength\plitemsep{1pt}+% \setlength\parskip{0pt}++\newcounter{pagesave}++% redefining the lhs2TeX code command is needed because+% TeXpower seems to tamper with \\ in some nasty way ...++% This one works:+%%subst code a = "\begingroup\parskip=\abovedisplayskip\par\advance\leftskip\mathindent\let\\=\origlinebreak\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\parskip=\belowdisplayskip\par\endgroup\resethooks'n"++% This one is with color:+%subst code a = "\begin{colorcode}'n" a "\end{colorcode}\resethooks'n" ++\definecolor{rlcolor}{gray}{.8}+\arrayrulecolor{rlcolor}+\definecolor{hcolor}{gray}{.7}++% \newenvironment{colorcode}{%+%   \parskip=\abovedisplayskip\par\noindent+%   \begingroup\small% small changes displayskips!+% %if color+%   \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+% %elif framed+%   \framed+% %else+%   \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%+%   \hline \\[-1.5ex]+%   \let\myendofline=\\+% %endif+%   \let\\=\origlinebreak+%   \(%+%   \pboxed\SaveRestoreHook}{%+%   \ColumnHook\endpboxed+%   \)%+% %if not color && not framed+%   \myendofline[.5ex]\hline+% %endif+% %if framed+%   \endframed+% %else+%   \endtabular+% %endif+%   \endgroup+%   \parskip=\belowdisplayskip\par\noindent+%   \ignorespacesafterend}++\newenvironment{colorcode}{%+  \colorsurround+  \(%+  \pboxed\SaveRestoreHook}{%+  \ColumnHook\endpboxed+  \)%+  \endcolorsurround}++% \newenvironment{colorsurround}{%+%   \parskip=\abovedisplayskip\par\noindent+%   \begingroup\small% small changes displayskips!+% %if color+%   \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+% %elif framed+%   \framed+% %else+%   \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%+%   \hline \\[-1.5ex]+%   \let\myendofline=\\+% %endif+%   \let\\=\origlinebreak}{%+% %if not color && not framed+%   \myendofline[.5ex]\hline+% %endif+% %if framed+%   \endframed+% %else+%   \endtabular+% %endif+%   \endgroup+%   \parskip=\belowdisplayskip\par\noindent+%   \ignorespacesafterend}++\newenvironment{colorsurround}{\colorverb}{\endcolorverb}++% \newenvironment{colorarray}{%+%   \parskip=\abovedisplayskip\par\noindent+%   \begingroup\small% small changes displayskips!+% %if color+%   \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+% %elif framed+%   \framed+% %else+%   \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%+%   \hline \\[-1.5ex]+%   \let\myendofline=\\+% %endif+%   \let\\=\origlinebreak+%   \(%+%   \array}{%+%   \endarray+%   \)%+% %if not color && not framed+%   \myendofline[.5ex]\hline+% %endif+% %if framed+%   \endframed+% %else+%   \endtabular+% %endif+%   \endgroup+%   \parskip=\belowdisplayskip\par\noindent+%   \ignorespacesafterend}++\newenvironment{colorarray}{%+  \colorsurround+  \(%+  \array}{%+  \endarray+  \)%+  \endcolorsurround}++\makeatletter+\newenvironment{colorverb}{%+  \parskip=\abovedisplayskip\par\noindent+  \begingroup\small% small changes displayskips!+%if color+  \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+%elif framed+  \framed+%else+  \tabular{@@{}||p{\linewidth-2\arraycolsep-2\arrayrulewidth-2pt}||@@{}}%+  \hline \\[-1.5ex]+  \let\myendofline=\\+%endif+  \let\\=\origlinebreak}{%+%if not color && not framed+  \myendofline[.5ex]\hline+%endif+%if framed+  \endframed+%else+  \endtabular+%endif+  \endgroup+  \parskip=\belowdisplayskip\par\noindent+  \ignorespacesafterend}+\makeatother++%%%+%%% "IMPORTANT" ENVIRONMENT+%%%++\newenvironment{important}[1][Important]%+  {\colorsurround+   \centering+   \bfseries\textsc{#1:}\ }%+  {\endcolorsurround}++%\definecolor{codecolor}{rgb}{.982, .902, .902}% original+%\definecolor{codecolor}{rgb}{1,.898,.667}% so'n orange+\definecolor{codecolor}{rgb}{1,1,.667}++%format forall(a) = "\forall " a "\relax"++%\usepackage{fonttabl}++\begin{document}++%\begingroup+%\texfamily+%\fonttable+%\endgroup++\title{@Guide2lhs2TeX@\\+  \smaller (for version \ProgramVersion)}+\author{{Ralf Hinze and Andres L\"oh}\\+  \smaller \tabular{c}+           Institut f\"ur Informatik III, Universit\"at Bonn\\+           R\"omerstra\ss e 164, 53117 Bonn, Germany\\+           \verb|{ralf,loeh}@informatik.uni-bonn.de|+           \endtabular}%+\date{\today}+\maketitle++\tableofcontents++%---------------------------------------------------------------------------+\section{About @lhs2TeX@}+%---------------------------------------------------------------------------++The program @lhs2TeX@ is a preprocessor+that takes as input a literate Haskell source file+(or something sufficiently alike) and produces as+output a formatted file that can be further processed+by \LaTeX.++For example, consider the following input file:+\input{HelloWorldInput}+If we run the following two commands on it+\input{HelloWorldDialogue}+then the resulting \PDF file will look similar to+\begin{colorsurround}+\input{HelloWorld}+%if color+\vspace*{-2\baselineskip}%+%endif+\end{colorsurround}+%if color+\vspace*{\belowdisplayskip}%+\par\noindent+%endif+The behaviour of @lhs2TeX@ is highly customizable.+For example, the argument @--poly@ in the call above+specifies one of several different \defined{style}s.+Depending on the selected style, @lhs2TeX@ can perform+quite different tasks. Here is a brief overview:+\begin{compactitem}+  \item \textbf{verb} (verbatim): format code completely verbatim+  \item \textbf{tt} (typewriter): format code verbatim, but allow special+    formatting of keywords, characters, some functions, \dots+  \item \textbf{math}: mathematical formatting with basic alignment,+    highly customizable+  \item \textbf{poly}: mathematical formatting with mutliple alignments,+    highly customizable, supersedes \textbf{math}+  \item \textbf{code}: delete all comments, extract sourcecode+  \item \textbf{newcode} (new code): delete all comments, extract sourcecode,+    but allow for formatting, supersedes \textbf{code}+\end{compactitem}++%%%+%%%++%---------------------------------------------------------------------------+\section{Installing @lhs2TeX@}+%---------------------------------------------------------------------------++There are two possibilities to install @lhs2TeX@:+\begin{compactitem}+\item Using Cabal.+\item Classic configure/make.+\end{compactitem}++\subsection{Using Cabal to install @lhs2TeX@}++This requires Cabal 1.1.6 or later. The process is then as usual:+\input{CabalInstallation}%+The third step requires write access to the installation location+and the \LaTeX\ filename database.++\subsection{configure/make}++The following instructions apply to Unix-like environments.  However,+@lhs2TeX@ does run on Windows systems, too. (If you would like to add+installation instructions or facilitate the installation procedure for+Windows systems, please contact the authors.)++Unpack the archive. Assume that it has been unpacked into directory+@/somewhere@. Then say+\input{InstallationInstructions}%+You might need administrator permissions to perform the @make install@+step. Alternatively, you can select your own installation location by+passing the @--prefix@ argument to @configure@:+\input{ConfigureCall}++With @lhs2TeX@ come a couple of library files (containing basic +@lhs2TeX@ formatting directives) that need to be found by the+@lhs2TeX@ binary. The default search path is as follows:+\input{SearchPath}%+\label{defaultsearchpath}%+Here, @{HOME}@ and @{LHS2TEX}@ denote the current values of+the environment variables @HOME@ and @LHS2TEX@. The double slash+at the end of each dir means that subdirectories are also scanned.+If @lhs2TeX@ is installed+to a non-standard path, you might want to set the environment+variable @LHS2TEX@ to point to the directory where+@lhs2TeX.fmt@ and the other library files have been installed to.++\begin{important}+To be able to use ``poly'' style, the two \LaTeX\ +packages\\ @polytable.sty@ and @lazylist.sty@ are required!+\end{important}+Both are included+in the @lhs2TeX@ distribution (they are not part of standard+\LaTeX\ distributions, although they are available from +\CTAN~\cite{polytable,lazylist}),+and are usually installed during the normal procedure. The+@configure@ script will determine whether a suitably recent+version of @polytable@ is installed on your system, and if+necessary, install both @polytable.sty@ and @lazylist.sty@ to+your \TeX\ system. If this is not desired or fails (because the+script cannot detect your \TeX\ installation properly),+the installation of these files can be disabled by passing +the option @--disable-polytable@ to @configure@. In this case, +the two files must be manually installed to+a location where your \TeX\ distribution will find them.+Assuming that you have a local \TeX\ tree at @/usr/local/share/texmf@,+this can usually be achieved by placing the files in the directory+@/usr/local/share/texmf/tex/latex/polytable@ and subsequently running+\input{MkTeXLsrCall}%+to update the \TeX\ filename database.++%%%+%%%++%---------------------------------------------------------------------------+\section{@lhs2TeX@ operation}+%---------------------------------------------------------------------------++When run on an input file, @lhs2TeX@ classifies the source file+into different blocks:+\begin{compactitem}+\item Lines indicating a Bird-style literate program (i.e. lines beginning+      with either @>@ or @<@) are considered as \defined{code blocks}.+\item Lines that are surrounded by @\begin{code}@ and @\end{code}@+      statements, or also by @\begin{spec}@ and @\end{spec}@+      statements, are considered as \defined{code blocks}. (Note that+      @lhs2TeX@ does not care if both styles of a literate program are+      mixed in one file. In this sense, it is more liberal than+      Haskell.)+\item Text between two \verb+@+ characters that is not in a code block+      is considered \defined{inline verbatim}. If a \verb+@+ is desired+      to appear in text, it needs to be escaped: \verb+@@+. There is no+      need to escape \verb+@+'s in code blocks.+\item Text between two @|@ characters that is not in a code block is+      considered \defined{inline code}. Again, @|@ characters that should+      appear literally outside of code blocks need to be escaped: @||@.+\item A @%@ that is followed by the name of an @lhs2TeX@ directive is+      considered as a \defined{directive} and may cause @lhs2TeX@ to+      take special actions. Directives are described in detail later.+\item Some constructs are treated specially, such as occurrences of+      the \TeX\ commands @\eval@, @\perform@, @\verb@ or of the \LaTeX\+      environment @verbatim@.+\item All the rest is classified as \defined{plain text}.+\end{compactitem}+Depending on the style in which it is called, @lhs2TeX@ will treat+these blocks in different ways.++%---------------------------------------------------------------------------+\section{Overview over the different styles}+%---------------------------------------------------------------------------++In this section, we will demonstrate on a common example how the+different styles can be used. For each style, there will also be+a short summary. Some of the points listed in the summary are+defaults for the particular style and can actually be changed.++%%%+%%%++\subsection{Verbatim: ``verb'' style}++In \textbf{verb} style, the code shows up in the formatted+document exactly as it has been entered, i.e. verbatim.+All spaces are preserved, and a non-proportional font is+used.+\input{Zip}%+One does not need @lhs2TeX@ to achieve such a result. This style,+however, does not make use of an internal \TeX\ verbatim construct.+The implementation of verbatim environments in \TeX\ is somewhat+restricted, and the preprocessor approach may prove more flexible+in some situations. For example, it is easier to apply additional+formatting instructions to the output as a whole, such as placing+the code in a colored box.++\paragraph{Verbatim summary}+\begin{compactitem}+\item formatting directives are ignored+\item conditionals and includes are handled+\item inline code, inline verbatim, and code blocks are all+      typeset completely verbatim, using a typewriter font+\item all spaces in code blocks are preserved+\item plain text is copied unchanged+\end{compactitem}++%%%+%%%++\subsection{Space-preserving formatting with ``tt'' style}++The \textbf{tt} style is very similar to \textbf{verb} style,+but applies a tiny bit of formatting to the code and allows+for more customizabilty:+\input{ZipTT}%+By default, some of the Haskell symbols are expressed more+naturally. For instance, special symbols are being used+for the arrows or the lambda. In addition, the user can+specify additional formatting directives to affect the appearance+of certain identifiers. In this way, keywords can be highlighted,+user-defined Haskell infix operators can be replaced by more+appropriate symbols etc. In this style, the layout and all+spaces from the source file are still preserved, and a non-proportional+font is used, as in \textbf{verb} style.++\paragraph{Typewriter summary}+\begin{compactitem}+\item non-recursive formatting directives are obeyed+\item conditionals and includes are handled+\item inline verbatim is typeset as verbatim, whereas inline+      code and code blocks are typeset almost verbatim, after+      formatting directives are applied, in a typewriter font+      using some special symbols to ``beautify'' some+      Haskell operators.+\item all spaces in code blocks are preserved+\item plain text is copied unchanged+\end{compactitem}++%%%+%%%++\subsection{Proportional vs.~Monospaced}++Usually, there is a tradeoff between restricting oneself to+the use of a typewriter font and not using any formatting and+using a proportional font, at the same time replacing operators+with mathematical symbols, using different font shapes to highlight+keywords etc. While the latter offers far more flexibility, the+proportional font might destroy (at least part of) the layout+that the programmer has employed in order to make the source+code more readable.++Compare, for example, the previous two examples with the+following result (this is a negative example, @lhs2TeX@ can+do far better than that!!):+\input{ZipStupid}%+\noindent+While the indentation is kept (otherwise, for the layout sensitive+Haskell it would be even disastrous, because the code might no+longer be valid), alignment that has been present in the code+lines has been lost. For example, in the input the user had decided+to align all equality symbols of all three function definitions,+and also align them with the ``has-type'' operator |::|.++Without support from a tool like @lhs2TeX@, the horizontal positions+of the equality symbols in the formatted code are totally unrelated.+A solution to this problem is of course to put the Haskell code in+a \LaTeX\ table. Doing this manually, though, is very cumbersome and+in some case still quite hard. The task of the formatted styles of+@lhs2TeX@ is thus to spare the user the burden of cluttering up+the code with formatting annotations. Most of the time, completely+un-annotated code can be used to achieve good results, using the+fonts you like while maintaining alignment information in the code!++%%%+%%%++\subsection{Alignment and formatting with ``math'' style}++In prior versions of @lhs2TeX@, \textbf{math} style was the mode+to use for formatted Haskell code. There is one alignment column,+often used to align the equality symbols of several equations.+Additionally, indentation is handled automatically. User-defined+formatting directives can be used to alter the formatting of+identifiers, operators and symbols in many places.+\input{ZipMath}%+\noindent+The example shows that there is still a loss of alignment information+compared to the original verbatim example. The three arguments of the+|zipWith| function as well as the two guarded equations+in the definition of |select| are not aligned. At the moment,+\textbf{math} style exists mainly to maintain compatibility with+old documents. New features may be added to \textbf{poly}+style only.++\paragraph{``math'' summary}+\begin{compactitem}+\item all formatting directives are obeyed+\item conditionals and includes are handled+\item inline verbatim is typeset as verbatim, whereas inline+      code and code blocks are typeset using a proportional+      font, using mathematical symbols to represent many Haskell+      operators.+\item indentation in code blocks is preserved; furthermore, alignment+      on a single column is possible+\item plain text is copied unchanged+\end{compactitem}++%%%+%%%++\subsection{Complex layouts: ``poly'' style}++The \textbf{poly} style has been designed to lift the restrictions+that \textbf{math} style still has. Multiple alignments and thus+complex layouts are possible:+\input{ZipPoly}%+If run in \textbf{poly} style, @lhs2TeX@ produces \LaTeX\ code+that makes use of the @polytable@ package, a package that has+been specifically designed to fit the needs that arise while+formatting Haskell code. (If you are interested in the package+or think that it might be useful for other purposes, you are+welcome to look at the documentation for +@polytable@~\cite[also distributed with @lhs2TeX@ as +@polytable.pdf@ in the @polytable@ directory]{polytable}.)++Beyond the advanced alignment options, \textbf{poly} style has+all the functionality of \textbf{math} style. If \textbf{poly}+style works for you, you should use it.++\paragraph{``poly'' summary}+\begin{compactitem}+\item all formatting directives are obeyed+\item conditionals and includes are handled+\item inline verbatim is typeset as verbatim, whereas inline+      code and code blocks are typeset using a proportional+      font, using mathematical symbols to represent many Haskell+      operators.+\item alignment can be flexibly specified; complex layouts+      are possible+\item plain text is copied unchanged+\end{compactitem}++%%%+%%%++\subsection{``poly'' style is customizable}++The following example demonstrates that the visual appearance+of ``poly'' style is in no way dictated by @lhs2TeX@. There+are several possibilities to modify the output by means+of formatting directives. Here, we try to mimic \textbf{tt}+style by choosing a typewriter font again and using the same+symbols that are default in \textbf{tt} style.+\input{ZipPolyTT}%+In contrast to the \textbf{tt} style example, here the spaces+in the code are \emph{not} preserved -- the alignment is generated+by the @polytable@ package.++%%%+%%%++\subsection{The ``code'' and ``newcode'' styles}++These two styles are not for producing a \LaTeX\ source file,+but rather produce a Haskell file again. Everything that is+not code is thrown away. In addition, \textbf{newcode} does+a few things extra. It applies formatting directives which+can here be used as simple macros on the Haskell source level,+and it generates line pragmas for the Haskell compiler that will+result in error messages pointing to the original file (before+processing with @lhs2TeX@). The plain \textbf{code} style+does not have this extra functionality. Again, \textbf{code}+is mainly intended for compatibility with old documents. You+should use \textbf{newcode}.++\paragraph{``code'' summary}+\begin{compactitem}+\item formatting directives are ignored+\item conditionals and includes are handled (??)+\item code blocks that are not specifications are copied unchanged+\item plain text, inline code, specification code, +      and inline verbatim are discarded+\end{compactitem}++\paragraph{``new code'' summary}+\begin{compactitem}+\item all formatting directives are obeyed+\item conditionals and includes are handled+\item code blocks that are not specifications are, after applying +      formatting directives, +      copied unchanged, prefixed by a line pragma indicating the+      original source location of the code block+\item plain text, inline code, specification code, +      and inline verbatim are discarded+\end{compactitem}+++%%%+%%%++%---------------------------------------------------------------------------+\section{Directives}+%---------------------------------------------------------------------------++A number of directives are understood by @lhs2TeX@. Some of the are+ignored in some of the styles, though.  Directives can occur on all+non-code lines and start with a @%@, the \TeX\ comment character,+immediately followed by the name of the directive, plus a list of+potential arguments.++While @lhs2TeX@ will remove directives that it has interpreted, it will +simply ignore all normal \TeX comments that are no directives. +Therefore, if a directive is accidentally misspelled, +no error message will be raised in general.++Table~\ref{directives} is a complete list of the directives +that @lhs2TeX@ knows about.+\begin{table}+\input{CompleteDirectives}%+\caption{All @lhs2TeX@ directives}\label{directives}+\end{table}+These directives will be explained in more or less detail in the+following sections.++%---------------------------------------------------------------------------+\section{Including files}+%---------------------------------------------------------------------------++Other files can be included by @lhs2TeX@. This is what the+@%include@ directive is for:+\input{IncludeSyntax}%+The specified file is searched for in the @lhs2TeX@ source path+which can be modified using environment variables or+the @-P@ command line option (see also page~\pageref{defaultsearchpath}).+Included files are inserted literally at the position of the+@%include@ directive. Because of that, the included files may not+only contain other sources, but also other directives (in particular,+an included file may contain an @%include@ directive again).+The @lhs2TeX@ is entirely independent of \TeX\ or Haskell includes/imports.++\begin{important}[Warning]+Although relative and absolute pathnames can be specified as part+of a filename in an @%include@ directive, the use of this feature+is strongly discouraged. Set the search path using the @-P@ command+line option to detect files to include.+\end{important}++If the @-v@ command line flag is set, @lhs2TeX@ will print the+paths of the files it is reading on screen while processing a file.++%%%+%%%++\subsection{The @lhs2TeX@ ``prelude''}++Several aspects of the behaviour of @lhs2TeX@ are not hardcoded,+but configurable via directives. As a consequence,+a minimal amount of functionality has to be defined for @lhs2TeX@+to be able to operate normally.++Essential definitions are collected in the file @lhs2TeX.fmt@.+\begin{important}[Note to users of previous versions]+There used to be a file @lhs2TeX.sty@ that also contained a part+of the prelude declarations. This file does still exist for+compatibility reasons, but is now deprecated. It should \emph{not}+be included directly in any of your documents anymore.+\end{important}+If you are using the \textbf{poly} or \textbf{newcode}+styles, some of the defaults in @lhs2TeX.fmt@ are sub-optimal.+In this case, there is a better prelude @polycode.fmt@ (which includes+@lhs2TeX.fmt@ in turn). One of the two files @lhs2TeX.fmt@ or @polycode.fmt@+should be included (using @%include@)+-- directly or indirectly -- in every file to be processed by+@lhs2TeX@!+\input{IncludePrelude}%+It is perfectly possible to design+own libraries that replace or extend these basic files and to include+those own libraries instead.  It is not recommended, though, to edit+these two files directly.  If you are not satisfied with some of the+default definitions, create your own file to redefine selected+parts. This way, if @lhs2TeX@ is updated, you will still be able to+benefit from improvements and changes in the ``prelude'' files.++It is possible to use @lhs2TeX@ in a setup where a \TeX\ document+is split into several files, and each of the files should be processed+separately by @lhs2TeX@. In this case, just include @lhs2TeX.fmt@+(or @polycode.fmt@) in every single file source file.++\begin{important}[Warning]+Note that both @lhs2TeX.fmt@ and @polycode.fmt@ contain @lhs2TeX@+directives, and therefore \emph{cannot} be included using \TeX\ or \LaTeX\+include mechanisms such as @\input@ or @\usepackage@.+\end{important}++%%%+%%%++% End of introduction part -- begin of reference++%%%+%%%++%%%+%%%++%%%+%%%++%---------------------------------------------------------------------------+\section{Formatting}+%---------------------------------------------------------------------------++Using the @%format@ directive, tokens can be given a different+appearance. The complete syntax that is supported by @lhs2TeX@ is+quite complex, but we will look at many different cases in detail.+\input{FormatSyntax}% There are three different forms of the+formatting statement.  The first one can be used to change the+appearance of most functions and operators and a few other+symbols. The second form is restricted to named identifiers (both+qualified and unqualified, but no symbolic operators); in turn,+such formatting directives can be parametrized. Finally, the third +form provides a syntactically+lightweight way of formatting certain identifiers using some+heuristics. But let us look at some common examples first \dots++%%%+%%%++\subsection{Formatting single tokens}++The most important use for @%format@ is to assign a symbol to+an identifier or an operator.+The input+\input{FormatGreekIn}%+produces output similar to the following:+\input{FormatGreekOut}%+The occurrences of @alpha@ within the Haskell code portions of+the input file are replaced by the \TeX\ command @\alpha@ and+thus appear as ``$\alpha$'' in the output.++A lot of formatting directives for frequently used identifiers+or operators is already defined in the @lhs2TeX@ prelude.+For instance, @++@ is formatted as ``|++|'', @undefined@ is+formatted as ``|undefined|'', and @not@ is formatted+as ``|not|''. If you look at @lhs2TeX.fmt@, you will find the+following directives that do the job:+\input{FormatIdentifierExamples}%+Here, @\plus@ refers to a \LaTeX\ macro defined in the lhs2\TeX\ prelude:+\input{PlusDefinition}%+If you are not satisfied with any of the default definitions,+just redefine them. A @%format@ directive scopes over the rest+of the input, and if multiple directives for the same token+are defined, the last one is used. Thus, after+\input{FormatIdentifierRedefs}%+%{+%format ++        = "\mathbin{\mathbf{+}}"+%format undefined = "\Varid{undefined}"+%format not       = "!"+you get ``|++|'', ``|undefined|'', and ``|not|'', respectively.+Note that @\Varid@ is a macro defined in the lhs2\TeX\ prelude that+can be used to typeset identifier names. It is predefined to+be the same as @\mathit@, but can be changed. Do not use identifier+names in \TeX\ replacements directly. For instance,+\input{FormatIdentifierWrong}%+%{+%format undefined  = "undefined"+will cause @undefined@ to be typeset as ``|undefined|'', which looks+by far less nice than+%}+``|undefined|''.+%}+It is also possible to define a symbol for infix uses of a+function. The file @lhs2TeX.fmt@ contains:+\input{FormatElem}%+This causes @2 `elem` [1,2]@ to be typeset as ``|2 `elem` [1,2]|'',+whereas @elem 2 [1,2]@ will still be typeset as ``|elem 2 [1,2]|''.++%%%+%%%++\subsection{Nested formatting}++The right hand sides of formatting directives are not restricted+to (\TeX-)strings. They can in fact be sequences of such strings or+other tokens, separated by space. Such other tokens will be replaced+by their formatting again. For example, if you have already defined+a specific formatting+\input{FormatArrow}%+%format ~> = "\leadsto "+then you can later reuse that formatting while defining variants:+\input{FormatArrow2}%+%format ~>* = ~> "^{" * "}"+As you can see, in this definition we reuse both the current formatting+for @~>@ and for @*@. We now get ``|~>*|'' for @~>*@, but should we+decide to define+\input{FormatStar}%+%format * = "\star "+later, we then also get ``|~>*|''. Of course, you can use the same+mechanism for non-symbolic identifiers:+\input{FormatId}%+%{+%format new      = "\mathbf{new}"+%format text0    = text+%format text_new = text "_{" new "}"+will cause @text0@ to be typeset as ``|text0|'', and @text_new@ will+appear as ``|text_new|''.+%}+\begin{important}[Warning]+There is no check for recursion in the formatting directives.+Formatting directives are expanded on-demand, therefore a directive+such as+\input{FormatRecurse}%+will not produce ``$\mathsf{text}$'' for @text@, but rather +cause an infinite loop in+@lhs2TeX@ once used.+\end{important}++%%%+%%%++\subsection{Parametrized formatting directives}++Formatting directives can be parametrized. The parameters may occur+once or more on the right hand side. This form of a formatting+directive is only available for alphanumeric identifiers. For+example, the input+\input{CardIn}%+produces output similar to+\begin{colorsurround}+\input{Card}+\end{colorsurround}+If the function is used with two few arguments as in the text,+a default symbol is substituted (usually a @\cdot@, but that is+customizable, cf. Section~\ref{subst}).++%%%+%%%++\subsection{(No) nesting with parametrized directives}++You cannot use a parametrized directive on the right hand side+of another directive. +In summary,+the right-hand sides of formatting directives are processed as follows:+\begin{compactitem}+\item A string, enclosed in @"@, will be reproduced literally (without+      the quotes).+\item A name, if it is the name of a parameter, will be replaced by the+      actual (formatted) argument.+\item A name, if it is the name of a non-parametrized formatting directive,+      will be replaced by that directive's replacement.+\item Any other name will be replaced by its standard formatting.+\end{compactitem}+Note that the spaces between the tokens do not occur in the output.+If you want spaces, insert them explicitly.++%%%+%%%++\subsection{Parentheses}++Sometimes, due to formatting an identifier as a symbol, parentheses+around arguments or the entire function become unnecessary.+Therefore, @lhs2TeX@ can be instructed to drop parentheses around an+argument by enclosing the argument on the left hand side of the+directive in parentheses. Parentheses around the entire function are+dropped if the entire left hand side of the directive is enclosed in+parentheses. Let us look at another example:+\input{ParensExampleIn}%+The above input produces the following output:+\begin{colorsurround}+\input{ParensExample}+\end{colorsurround}+Note that in this example a special purpose operator, @^^@, is used+to facilitate the insertion of spaces on the right hand side of a+formatting directive. Read more about influencing spacing using formatting+directives in Section~\ref{spacing}.+Another example involving parentheses: the input+\input{ParensExample2In}%+results in       +\begin{colorsurround}+\input{ParensExample2}+\end{colorsurround}+++%%%+%%%++\subsection{Local formatting directives}++Usually, formatting directives scope over the rest of the input.+If that is not desired, formatting directives can be placed into+\textbf{groups}. Groups look as follows:+\input{GroupSyntax}%+Formatting directives that are defined in a group scope only over+the rest of the current group. Groups can be nested. Groups in+@lhs2TeX@ do not interact with \TeX\ groups, so these different+kinds of groups do not have to occur properly nested.++The effect of groups is made visible by the example input+\input{GroupExampleIn}+which appears as follows:+\begin{colorsurround}+\input{GroupExample}+\end{colorsurround}++%%%+%%%++\subsection{Implicit formatting}++The third syntactic form of the formatting directive, lacking a+right hand side, can be used to easily format a frequently occurring+special case:+only a variable (or constructor) name that ends in a number or a prime @'@+can be used in an implicit formatting statement.+The prefix will then be formatted as determined by the formatting directives+in the input so far. The number will be added as an index, the prime +character as itself.++The following input contains some example:+\input{ImplicitIn}+The corresponding output is:+\begin{colorsurround}+\input{Implicit}+\end{colorsurround}++Another form of implicit formatting only takes place only if the token to+be formatted does not end in primes, and only if digits at the end are +immediately preceded by an underscore. The reason for these conditions is+compatibility. If the conditions are met, then the token is split at+underscores, and the part to the right of an underscore is typeset as+subscript to the part on the left, recursively. Again, let us look at an+example:+\input{ImplicitUnderscoreIn}+And its output:+\begin{colorsurround}+\input{ImplicitUnderscore}+\end{colorsurround}++%%%+%%%++\subsection{Formatting behaviour in different styles}++\begin{compactitem}+\item Formatting directives are applied in \textbf{math}, \textbf{poly}, and+      \textbf{newcode} styles.+\item In \textbf{tt} style, only non-parametrized directives apply.+\item In \textbf{verb} and \textbf{code} styles, formatting directives are ignored.+\end{compactitem}+A document can be prepared for processing in different styles +using conditionals (cf.~Section~\ref{conditionals}).++%%%+%%%++%---------------------------------------------------------------------------+\section{Alignment in ``poly'' style}+%---------------------------------------------------------------------------++The second important feature of @lhs2TeX@ next to the ability to+change the appearance of tokens is the possibility to maintain+alignment in the code while using a proportional font.++Use of this feature is relatively simple:+\begin{compactitem}+\item Alignment is computed per code block.+\item All tokens that start on the same column and are preceded by at+      least \textbf{2} spaces are horizontally aligned in the output.+\end{compactitem}+Using these simple rules, (almost) everything is possible, but it+is very important to verify the results and watch out for accidental+alignments (i.e.~tokens that get aligned against intention).++%%%+%%%++\subsection{An example}++The following example shows some of the potential. This is the+input:+\input{RepAlgIn}%+Look at the highlighted (grey) tokens. The @lt@ will not appear+aligned with the two equality symbols, because it is preceded by+only one space. Similarly, the @m@ in the first line after the+@Leaf@ constructor will not be aligned with the declarations and+the body of the let-statement, because it is preceded by only+one space. Note furthermore that the equality symbols for the+main functions @rep_alg@ and @replace_min'@ are surrounded by two+spaces on both sides, also on the right. This causes the comma+and the closing parenthesis to be aligned correctly.++Indeed, the output looks as follows:+\input{RepAlg}%+++%%%+%%%++\subsection{Accidental alignment}++The main danger of the alignment heuristic is that it results+in \emph{more} alignments than are intended. The following+example input contains such a case:+\input{AccidentalIn}%+The grey tokens will be unintentionally aligned because+they start on the same column, with two or more preceding spaces+each. The output looks as follows:+\input{Accidental}%+The ``|::|'' and the ``|=|'' have been aligned with the declarations+of the where-clause. This results in too much space between+the two |options| tokens and the symbols. Even worse, in this+case the \emph{centering} of the two symbols is destroyed by+the alignment (cf. Section~\ref{centering}), therefore ``|::|''+and ``|=|'' appear left-aligned, but not cleanly, because+\TeX\ inserts a different amount of whitespace around the two+symbols.++The solution to all this is surprisingly simple: just insert extra+spaces in the input to ensure that unrelated tokens start on different+columns:+\input{AccidentalCIn}%+This input produces the correct output:+\input{AccidentalC}%++%%%+%%%++\subsection{The full story}++If you further want to customize the alignment behaviour, you can.+Here is exactly what happens:+\begin{compactitem}+\item Alignment is computed per code block.+\item Per code block there are a number of \textbf{alignment columns}.+\item If a token starts in column |n| and is prefixed by at least +      ``\emph{separation}''+      spaces, then |n| is an \textbf{alignment column} for the code block.+\item If a token starts in an alignment column |n| and is prefixed by at least +      ``\emph{latency}''+      spaces, then the token is \textbf{aligned} at column |n|.+\item All tokens that are aligned at a specific column will appear aligned+      (i.e. at the same horizontal position) in the output.+\end{compactitem}+Both latency and separation can be modified by means of associated+directives:+\input{SepLatSyntax}%+It can occasionally be useful to increase the default settings of 2 and+2 for large code blocks where accidental alignments become very+likely! It does not really make sense to set latency to a value that+is strictly smaller than the separation, but you can do so -- there+are no checks that the specified settings are sensible.++%%%+%%%++\subsection{Indentation in ``poly'' style}++Sometimes, @lhs2TeX@ will insert additional space at the beginning+of a line to reflect indentation. The rule is described in the+following.++If a line is indented in column |n|, then+the \emph{previous} code line is taken into account:+\begin{compactitem} +\item If there is an aligned token at column |n| in the previous+      line, then the indented line will be aligned normally.+\item Otherwise, the line will be indented with respect to the+      first aligned token in the previous line to the left of column |n|.+\end{compactitem}++The first example demonstrates the first case:+\input{Indent1In}%+In this example, there is an aligned token in the previous line+at the same column, so everything is normal.+The two highlighted parentheses are aligned, causing the+second line to be effectively indented:+\input{Indent1}%+The next example demonstrates the second case. It is the same+example, with one space before the two previously aligned parentheses+removed:+\input{Indent2In}%+Here, there is no aligned token in the previous line+at the same column. Therefore, the third line is indented with+respect to the first aligned token in the previous line to the+left of that column, which in this case happens to be the @xs@:+\input{Indent2}%+Sometimes, this behaviour might not match the intention of+the user, especially in cases as+above, where there really starts a token at the same position+in the previous line, but is not preceded by enough spaces.+Always verify the output if the result looks as desired.++The amount of space that is inserted can be modified. A call+to the \TeX\ control sequence @\hsindent@ is inserted at the+appropriate position in the output, which gets as argument the+column difference in the source between the token that is +indented, and the base token. In the situation of the+above example, the call is @\hsindent{12}@. The default definition+in the lhs2\TeX\ prelude+ignores the argument and inserts a fixed amount of space:+\input{HsIndent}%++Here is another example that shows indentation in action, the+Haskell standard function |scanr1| written using only basic+pattern matching:+\input{Indent2aIn}%+And the associated output:+\input{Indent2a}%++%%%+%%%++\subsection{Interaction between alignment and indentation}++In rare cases, the indentation heuristic can lead to surprising+results. This is an example:+\input{Indent3In}%+And its output:+\input{Indent3}%+Here, the large amount of space between |test| and+|1| might be surprising. However, the |1| is aligned with the |2|, +but |2| is also indented with respect to |bar|, so everything+is according to the rules. The ``solution'' is to verify if both+the alignment between |1| and |2| and the indentation of the |2|+are intended, and to remove or add spaces accordingly.++%%%+%%%++\subsection{Interaction between alignment and formatting}++If a token at a specific column is typeset according to a formatting+directive, then the first token of the replacement text inherits the+column position of the original token. The other tokens of the+replacement text will never be aligned. Actual arguments of+parametrized formatting directives keep the column positions they have+in the input.++%%%+%%%++\subsection{Centered and right-aligned columns}\label{centering}++Under certain circumstances @lhs2TeX@ decides to typeset a+column centered instead of left-aligned. This happens if the+following two conditions hold:+\begin{compactitem}+\item There is \emph{at most one} token per line that is associated+      with the column.+\item \emph{At least one} of the tokens associated with the column+      is a symbol.+\end{compactitem}+In most cases, this matches the intention. If it does not, there+still might be the possibility to trick @lhs2TeX@ to do the right+thing:+\begin{compactitem}+\item Change the alignment behaviour of the column using+      @\aligncolumn@ (see below).+\item If the column is centered but should not be, add extra+      tokens that are formatted as nothing that will be associated+      with the column (see also Section~\ref{spacing} about spacing).+\item If the column should be centered but is left-aligned, it is+      sometimes possible to use a symbol instead of an alphanumeric+      identifier, and add a formatting directive for that newly+      introduced symbol.+\end{compactitem}++The syntax of the @\aligncolumn@ command is:+\input{AlignColumnSyntax}%+% The above file also contains some additional documentation.++TODO: ADD EXAMPLE!!++%%%+%%%++\subsection{Saving and restoring column information}++It is possible to share alignment information between different+code blocks. This can be desirable, especially when one wants+to interleave the definition of a single function with longer+comments. This feature is implemented on the \TeX\ level +(the commands are defined in the lhs2\TeX\ prelude).++Here is an example of its use:+\input{SaveRestoreIn}%+As output we get:+\begin{colorsurround}+\input{SaveRestore}+\end{colorsurround}+Compare this to the output that would be generated +without the @\savecolumns@ and @\restorecolumns@ commands:+\begin{colorsurround}+\input{SaveRestoreNo}+\end{colorsurround}++\begin{important}+If this feature is used, it may require several runs of \LaTeX\ until+all code blocks are correctly aligned. Watch out for warnings+of the @polytable@ package that tell you to rerun \LaTeX!+\end{important}++%---------------------------------------------------------------------------+\section{Defining variables}\label{variables}+%---------------------------------------------------------------------------++One can define or define flags (or variables) by means of the+@%let@ directive.+\input{LetSyntax}%+Expressions are built from booleans (either @True@ or @False@),+numerals (integers, but also decimal numbers) and previously defined+variables using some fixed set of builtin operators. The expression+will be evaluated completely at the time the @%let@ directive+is processed. If an error occurs during evaluation, @lhs2TeX@ will+fail.++Variables can also be passed to @lhs2TeX@ from the operating+system level by using the @-l@ or @-s@ command line options.++The main use of variables is in conditionals +(cf.~Section~\ref{conditionals}).+At the moment, there is no way to directly use the value of a+variable in a @%format@ directive.++%%%+%%%++\subsection{Predefined variables}++In every run of @lhs2TeX@, the version of @lhs2TeX@ is available+as a numerical value in the predefined variable @version@. Similarly,+the current style is available as an integer in the predefined +variable @style@. There also are integer variables @verb@, @tt@, +@math@, @poly@, @code@, and @newcode@ predefined that can be used+to test @style@.++It is thus possible to write documents in a way that they can be+processed beautifully in different styles, or to make safe use of+new @lhs2TeX@ features by checking its version first.++%%%+%%%++%---------------------------------------------------------------------------+\section{Conditionals}\label{conditionals}+%---------------------------------------------------------------------------++Boolean expressions can be used in conditionals. The syntax of an+@lhs2TeX@ conditional is+\input{IfSyntax}%+where the @%elif@ and @%else@ directives are optional. There may+be arbitrarily many @%elif@ directives. When an @%if@ directive+is encountered, the expression is evaluated, and depending on the+result of the evaluation of the expression, only the then or only+the else part of the conditional is processed by @lhs2TeX@, the+other part is ignored.++%%%+%%%++\subsection{Uses of conditionals}++These are some of the most common uses of conditionals:+\begin{compactitem}+\item One can have different versions of one paper in one (set of)+      source file(s). Depending+      on a flag, @lhs2TeX@ can produce either the one or the other. +      Because the flag can be defined via a command +      line option (cf.~Section~\ref{variables}), +      no modification of the source is necessary to switch versions.+\item Code that is needed to make the Haskell program work but that+      should not appear in the formatted article (module headers,+      auxiliary definitions), can be enclosed between @%if False@+      and @%endif@ directives.+\item Alternatively, if Haskell code has to be annotated for +      @lhs2TeX@ to produce aesthetically pleasing output, one can +      define different formatting directives for+      the annotation depending on style (\textbf{poly} or \textbf{newcode}).+      Both code and \TeX\ file can then still be produced from a+      common source! Section~\ref{generichaskell} contains an example+      that puts this technique to use.+\end{compactitem}++The lhs2\TeX\ library files use conditionals to+include different directives depending on the style selected, but+they also use conditionals to provide additional or modified behaviour+if some flags are set. These flags are @underlineKeywords@,+@spacePreserving@, @meta@ (activate a number of additional formatting+directives), @array@ (use @array@ environment instead of @tabular@+to format code blocks in \textbf{math} style; use @parray@ instead+of @pboxed@ in \textbf{poly} style), @latex209@ (adapt for use with+\LaTeX\ 2.09 (not supported anymore)), @euler@, and @standardsymbols@. +%TODO: document the purpose of these flags better. +It is likely that these flags+will be replaced by a selection of library files that can be selectively+included in documents in future versions of @lhs2TeX@.++%%%+%%%++%---------------------------------------------------------------------------+\section{Typesetting code beyond Haskell}+%---------------------------------------------------------------------------++\subsection{Spacing}\label{spacing}++There is no full Haskell parser in @lhs2TeX@. Instead, the input+code is only lexed and subsequently parsed by an extremely simplified+parser. The main purpose of the parser is to allow a simple heuristic+where to insert spaces into the output while in \textbf{math} or+\textbf{poly} style. ++The disadvantage is that in+rare cases, this default spacing produces unsatisfying results.+However, there is also a big advantage: dialects of Haskell can+be processed by @lhs2TeX@, too. In theory, even completely +different languages can be handled. The more difference between+Haskell and the actual input language, the more tweaking is probably+necessary to get the desired result.++An easy trick to modify the behaviour of @lhs2TeX@ is to insert+``dummy'' operators that do not directly correspond to constructs+in the input language, but rather provide hints to @lhs2TeX@ on+how to format something. For instance, spacing can be+guided completely by the following two formatting directives:+\input{SpacingOps}%+Use @^@ everywhere where \emph{no} space is desired, but the+automatic spacing of @lhs2TeX@ would usually place one.+Conversely, use @^^@ everywhere where a space \emph{is} desired,+but @lhs2TeX@ does usually not place one.++As described in Section~\ref{conditionals}, one can use conditionals+to format such annotated input code in both \textbf{poly} +(or \textbf{math}) and \text{newcode} style to generate both typeset+document and code with annotation remove from a single source file.+For this to work correctly, one would define+\input{SpacingOpsCond}%+as an extended version of the above. This instructs @lhs2TeX@ to+ignore @^@ and replace @^^@ by a single space while in \textbf{newcode}+style, and to adjust spacing in other styles, as before.++The examples in the following subsections show these directives+in use.++%%%+%%%++\subsection{Inline \TeX}++Another possibility that can help to trick @lhs2TeX@ into doing things+it normally doesn't want to is to insert inline \TeX\ code directly+into the code block by using a special form of Haskell comment:+\input{InlineTeXSyntax}%+% The above file also contains some additional documentation.+The advantage of this construct over a dummy operator+is that if the input language is indeed Haskell, one does not need+to sacrifice the syntactic validity of the source program for nice+formatting. On the other hand, inline \TeX\ tends to be more verbose+than an annotation using a formatting directive.++%%%+%%%++\subsection{{\smaller AG} code example}++Here is an example that shows how one can typeset code of the+Utrecht University Attribute Grammar ({\smaller UUAG}) +(\cite{uuag}) system,+which is based on Haskell, but adds additional syntactic constructs.++The input+\input{AGExampleIn}%+produces the following output:+\input{AGExample}++%%%+%%%++\subsection{Generic Haskell example}\label{generichaskell}++Another example of a Haskell variant that can be typeset using+@lhs2TeX@ using some annotations is Generic Haskell~\cite{gh}.++This is a possible input file, including the directives+necessary to be able to process it in both \textbf{newcode}+and \textbf{poly} style.+\input{GHExampleIn}%+Processed in \textbf{poly} style, the output looks as follows:+\input{GHExample}%++%%%+%%%++\subsection{Calculation example}++The following example shows a calculational proof. The input+\input{CalcExampleIn}%+produces+\input{CalcExample}%+++%%%+%%%++%---------------------------------------------------------------------------+\section{Calling @hugs@ or @ghci@}+%---------------------------------------------------------------------------++It is possible to call @ghci@ or @hugs@ using the @%options@+directive. In all but the two \textbf{code} styles, @lhs2TeX@+looks for calls to the \textbf{\TeX\ commands} @\eval@ and+@\perform@ and feeds their arguments to the Haskell interpreter+selected.++The current input file will be the active module. This has a+couple of consequences: on the positive side, values defined in+the current source file may be used in the expressions; on the+negative side, the feature will only work if the current file+is accepted as legal input by the selected interpreter.++If the command line in the @%options@ directive starts with+@ghci@, then @lhs2TeX@ assumes that @ghci@ is called; otherwise,+it assumes that @hugs@ is called. Depending on the interpreter,+@lhs2TeX@ will use some heuristics to extract the answer from+the output of the interpreter. After this extraction, the result+will either be printed as inline verbatim (for a @\perform@) or+as inline code (for @\eval@), to which formatting directives+apply.++\begin{important}[Warning]+This feature is somewhat fragile: different versions of @ghci@+and @hugs@ show different behaviour, and the extraction heuristics+can sometimes fail. Do not expect too much from this feature.+\end{important}++%%%+%%%++\subsection{Calling @ghci@ -- example}++The following input shows an example of how to call @ghci@:+\input{InteractiveGhciIn}%+The option @-fglasgow-exts@ is necessary to make @ghci@+accept the @forall@ keyword (it only serves as an example+here how to pass options to the interpreter). +The output will look similar to this:+\begin{colorsurround}+\input{InteractiveGhci}+\end{colorsurround}+Note that it is possible to pass interpreter commands such+as @:t@ to the external program. +%(ADAPT EXAMPLE TO SHOW THIS:)+%Note furthermore the difference+%in output between an @\eval@ and a @\perform@ command.++%%%+%%%++\subsection{Calling @hugs@ -- example}++The same could be achieved using @hugs@ instead of @ghci@.+For this simple example, the output is almost indistinguishable,+only that @hugs@ usually does not print type signatures using+explicit quantification and tends to use different variable+names.+\input{InteractiveHugsIn}%+The input is the same except for the changed @%options@+directive. The output now looks as follows:+\begin{colorsurround}+\input{InteractiveHugs}+\end{colorsurround}++%%%+%%%++\subsection{Using a preprocessor}++The situation is more difficult if the current @lhs2TeX@+source file is not valid input to the interpreter, because+annotations were needed to format some Haskell extensions+satisfactory. The following input file makes use of Template+Haskell, and uses the formatting directives for both+\textbf{newcode} and \textbf{poly} style. The @%options@+directive instructs @ghci@ to use @lhs2TeX@ itself as+the literate preprocessor, using the @-pgmL@ option of @ghci@.+The @lhs2TeX@ binary itself acts as a suitable literate +preprocessor if the @--pre@ command line option is passed, which+is achieved using the @-optL--pre@ option:+\input{InteractivePreIn}%+This is the corresponding output:+\begin{colorsurround}+\input{InteractivePre}+\end{colorsurround}+++%---------------------------------------------------------------------------+\section{Advanced customization}\label{subst}+%---------------------------------------------------------------------------++There is one directive that has not yet been described: @%subst@.+This directive is used by @lhs2TeX@ to customize almost every aspect+of its output. The average user will and should not need to use+a @%subst@ directive, but if one wants to influence the very nature+of the code generated by @lhs2TeX@, the @%subst@ directives provide+a way to do it.++If one would, for instance, want to generate output for another+\TeX\ format such as plain\TeX\ or Con\TeX t, or if one would want+to use a different package than @polytable@ to do the alignment+on the \TeX\ side, then the @%subst@ directives are a good place to+start. The default definitions can be found in @lhs2TeX.fmt@.++Table~\ref{substs} shows only a short description of the approximate+use of each of the categories.++\begin{table}+\centering+\begin{colorsurround}+\begin{tabularx}{\linewidth}{lX}+@thinspace@   & how to produce a small quantity of horizontal space \\+@space@       & how to produce a normal horizontal space \\+@newline@     & how to produce a new line inside a code block \\+@verbnl@      & how to produce a new line in @lhs2TeX@ generated verbatim \\+@blankline@   & how to translate a blank line in a code block \\+@dummy@       & how to display a missing argument in a formatted function \\+@spaces@ |a|  & how to format the whitespace contained in |a| \\+@special@ |a| & how to format the special character |a| \\+@verb@ |a|    & how to format the (already translated) inline +                verbatim text~|a| \\+@verbatim@ |a|& how to format an (already translated) verbatim block |a| \\+@inline@ |a|  & how to format (already translated) inline code |a| \\+@code@ |a|    & how to format an (already translated) code block |a| \\+@conid@ |a|   & how to format an identifier starting with an upper-case+                character |a| \\+@varid@ |a|   & how to format an identifier starting with a lower-case+                character |a| \\+@consym@ |a|  & how to format a constructor symbol |a| \\+@varsym@ |a|  & how to format a variable symbol |a| \\+@numeral@ |a| & how to format a numeral |a| \\+@char@ |a|    & how to format a character literal |a| \\+@string@ |a|  & how to format a literal string |a| \\+@comment@ |a| & how to format an (already translated) one-line comment |a| \\+@nested@ |a|  & how to format an (already translated) nested comment |a| \\+@pragma@ |a|  & how to format an (already translated) compiler pragma |a| \\+@keyword@ |a| & how to format the Haskell keyword |a| \\+@column1@ |a| & how to format an (already translated) line |a| +                in one column in \textbf{math} style \\+@hskip@ |a|   & how to produce a horizontal skip of |a| units \\+@phantom@ |a| & how to produce horizontal space of the width of the+                (already translated) text |a| \\+@column3@ |a| & how to format an (already translated) line |a|+                in three columns in \textbf{math} style \\+@fromto@ |b e a| & how to format a column starting at label |b|,+                ending at label |e|, containing the (already translated)+                code |a| in \textbf{poly} style \\+@column@ |n a| & how to define a column of label |n| with (already+                processed) format string |a| in \textbf{poly} style \\+@centered@    & the format string to use for a centered column \\+@left@        & the format string to use for a left-aligned column \\+@dummycol@    & the format string to use for the dummy column+                (a column that does not contain any code; needed+                due to deficiencies of the @polytable@ implementation) \\+@indent@ |n|  & how to produce an indentation (horizontal space) +                of |n| units \\+\end{tabularx}+\end{colorsurround}+\caption{A short description of the @%subst@ directives}\label{substs}+\end{table}+++%%%+%%%++% %---------------------------------------------------------------------------+% \section{Implementation and distribution}+% %---------------------------------------------------------------------------+% +% \begin{compactitem}+% \item @lhs2TeX@ is written in Haskell+% \item \textbf{poly} style makes use of a specifically written \LaTeX\ package+%       @polytable@, which is included in the distribution+% \item License is {\smaller GPL}.+% \item There has not been an official release for a long time, so get the+%       most recent version from {\smaller CVS} (or subversion soon).+% \item It does work on Unix-alikes. It should work on Windows/Cygwin, and+%       on native Windows with minor modifications -- help welcome.+% \item It has been used for several recent papers and seems to be quite stable.+% \end{compactitem}+% +% %%%+% %%%+% +% %---------------------------------------------------------------------------+% \section{Future work}+% %---------------------------------------------------------------------------+% +% \begin{compactitem}+% \item More language independence (customizable lexer).+% \item Clean up (and extend) the formatting directives language.+% \item Allow directives during code blocks.+% \item Add more features to @polytable@ package.+% \item \dots+% \end{compactitem}+% Future development is relatively low priority, though.+% If you want it, do it yourself or try to convince me+% that it is urgent!++\newenvironment{problem}%+  {\medskip\par\noindent\bfseries\ignorespaces}{\ignorespacesafterend}++%%%+%%%++% \section{History of @lhs2TeX@}+% +% \begin{compactitem}+% \item Ralf Hinze started development in 1997. Most of the hard work has+%   been done by him!+% \item The program is based on @smugweb@ and @pphs@, both of which are+%   no longer available and I do not know.+% \item I picked up development in 2002, and added+%   the \textbf{poly} and \textbf{newcode} styles.+% %\item Future: I consider the \textbf{tt} and \textbf{math} styles as deprecated,+% %  I want to add more language independence (customizable lexer) and +% %  extend/improve the formatting language.+% \end{compactitem}++%---------------------------------------------------------------------------+\section{Pitfalls/FAQ}+%---------------------------------------------------------------------------++\begin{problem}+The document consists of multiple files. Can @lhs2TeX@ be used?+\end{problem}+One option is to use @%include@ rather than \LaTeX\ commands+to include all files in the master file. The other is to process+all files that contain code \emph{and} the master file with @lhs2TeX@.+All files to be processed with @lhs2TeX@ must contain an+@%include lhs2TeX.fmt@ (or @%include polycode.fmt@) statement. +From version 1.11 on, including @lhs2TeX.sty@ is no longer necessary.++\begin{problem}+Yes, but the master file should be pure \LaTeX.+\end{problem}+Create a file @mylhs2tex.lhs@ with just one line, namely+@%include lhs2TeX.fmt@. Process that file with @lhs2TeX@, using the+options you also use for the other included files. Call the resulting+file @mylhs2tex.sty@ and say @\usepackage{mylhs2tex}@ at the beginning+of your master file.++\begin{problem}+The spacing around my code blocks is bad (nonexistent) in ``\textbf{poly}''+style.+\end{problem}+Add the line @%include polycode.fmt@ to the preamble of your document.++\begin{problem}+\LaTeX\ complains when using @lhs2TeX@ in ``\textbf{poly}'' style+with the @beamer@ package.+\end{problem}+Add the line @%include polycode.fmt@ to the preamble of your document.++\begin{problem}+\LaTeX\ complains when using @lhs2TeX@ in ``\textbf{poly}'' style+with the @jfp@ class.+\end{problem}+Add the line @%include jfpcompat.fmt@ to the preamble of your document.++\begin{problem}+\LaTeX\ claims that the package @polytable@ (or @lazylist@) +cannot be found, or that the version installed on your system+is too old.+\end{problem}+Did you install @polytable.sty@ (or @lazylist.sty@) +in your \TeX\ system manually?+If you have absolutely no idea how to do this, you may try to+copy both @polytable.sty@ and @lazylist.sty@ from the+@lhs2TeX@ distribution into your working directory.++\begin{problem}+Haskell strings are displayed without double quotes. +\end{problem}+This is+a result from using an old @lhs2TeX.fmt@ file together with+a new version of @lhs2TeX@. Usually, this stems from the fact+that there is an old version in the working directory. Now,+@lhs2TeX@ maintains a search path for included files, thus+usually a local old copy of @lhs2TeX.fmt@ can be removed.++\begin{problem}+In ``math'' style, I have aligned several symbols on one+column, but @lhs2TeX@ still won't align the code block.+\end{problem}+Did you set the alignment column correctly using the @%align@+directive? Note also that @lhs2TeX@ starts counting columns+beginning with |1|, whereas some editors might start counting+with |0|.++\begin{problem}+Large parts of the formatted file look completely garbled.+Passages are formatted as code or verbatim, although they are +plain text. Conversely, things supposed to be code or verbatim+are typeset as text.+\end{problem}+You probably forgot multiple @|@ or \verb+@+ characters.+Because @lhs2TeX@ identifies both the beginning and end of+inline code or inline verbatim via the same character, one+missing delimiter can confuse @lhs2TeX@ and cause large+passages to be typeset in the wrong way. You should locate+the first position in the document where something goes wrong+and look for a missing delimiter at the corresponding position +in the source file.++\begin{problem}+\LaTeX\ complains about a ``nested @\fromto@'' in ``poly'' style.+\end{problem}+This usually is a problem with one of your formatting directives.+If you start a \TeX\ group in one of your directives but do not+close it, then this error arises. You should not write such unbalanced+formatting directives unless you make sure that they do never span+an aligned column.+%TODO: Write example.++\begin{thebibliography}{99}++\bibitem{polytable}+  Andres L\"oh. \emph{The @polytable@ package.}+  \url{http://ctan.org/tex-archive/macros/latex/contrib/polytable/}++\bibitem{lazylist}+  Alan Jeffrey. \emph{The @lazylist@ package.}+  \url{http://ctan.org/tex-archive/macros/latex/contrib/lazylist/}++\bibitem{uuag}+  Arthur Baars, S.~Doaitse Swierstra, Andres L\"oh.+  \emph{The UU AG System User Manual.}+  \url{http://www.cs.uu.nl/~arthurb/data/AG/AGman.pdf}++\bibitem{array}+  Frank Mittelbach and David Carlisle.+  \emph{The @array@ package.}+  \url{http://www.ctan.org/tex-archive/macros/latex/required/tools/array.dtx}++\bibitem{gh}+  Andres L\"oh.+  \emph{Exploring Generic Haskell.}+  PhD Thesis, Utrecht University, 2004.++\end{thebibliography}++\end{document}++%%%+%%%++\section{Test}++\input{Variable}+++%%%+%%%++++++\end{document}+
+ doc/Guide2.pdf view

binary file changed (absent → 319611 bytes)

+ doc/HelloWorld.lhs view
@@ -0,0 +1,8 @@+%include poly.fmt++This is the famous ``Hello world'' example, +written in Haskell:+\begin{code}+main  ::  IO ()+main  =   putStrLn "Hello, world!"+\end{code}
+ doc/HelloWorldDialogue.lhs view
@@ -0,0 +1,9 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+$ lhs2TeX -o HelloWorld.tex HelloWorld.lhs+$ pdflatex HelloWorld.tex+\end{code}+\endgroup
+ doc/HelloWorldInput.lhs view
@@ -0,0 +1,17 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\documentclass{article}+>%include polycode.fmt+>\begin{document}+>This is the famous ``Hello world'' example, +>written in Haskell:+>\begin{code}+>main  ::  IO ()+>main  =   putStrLn "Hello, world!"+>\end{code}+>\end{document}++\endgroup
+ doc/HsIndent.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\newcommand{\hsindent}[1]{\quad}++\endgroup
+ doc/IfSyntax.lhs view
@@ -0,0 +1,12 @@+%include tex.fmt+%format ... = "\dots "++\begin{code}+dir(^if^) ^^ ent(expression)+...+dir(elif) ^^ ent(expression)+...+dir(^else^)+...+dir(endif)+\end{code}
+ doc/Implicit.lhs view
@@ -0,0 +1,8 @@+%include poly.fmt++%format omega = "\omega"+|[omega, omega13, omega13']|\par+%format omega13+|[omega, omega13, omega13']|\par+%format omega13'+|[omega, omega13, omega13']|
+ doc/ImplicitIn.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>%format omega = "\omega"+>|[omega, omega13, omega13']|\par+>%format omega13+>|[omega, omega13, omega13']|\par+>%format omega13'+>|[omega, omega13, omega13']|+\endgroup
+ doc/ImplicitUnderscore.lhs view
@@ -0,0 +1,20 @@+%include poly.fmt++%format a_i+%format a_j+%format left  = "\leftarrow "+%format right = "\rightarrow "+%format a_left+%format a_right+%format a_let+%format a_where+%format a_x_1+%format a_x_2+%format y_1+%format y_2+%format a_y_1+%format a_y_2+%format a_y1+%format a_i'+|[a_i,a_j,a_left,a_right,a_let,a_where,a_x_1,a_x_2,a_y_1,a_y_2,a_y1,a_i']|+
+ doc/ImplicitUnderscoreIn.lhs view
@@ -0,0 +1,22 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>%format a_i+>%format a_j+>%format left  = "\leftarrow "+>%format right = "\rightarrow "+>%format a_left+>%format a_right+>%format a_let+>%format a_where+>%format a_x_1+>%format a_x_2+>%format y_1+>%format y_2+>%format a_y_1+>%format a_y_2+>%format a_y1+>%format a_i'+>|[a_i,a_j,a_left,a_right,a_let,a_where,a_x_1,a_x_2,a_y_1,a_y_2,a_y1,a_i']|+\endgroup
+ doc/IncludePrelude.lhs view
@@ -0,0 +1,6 @@+%include tex.fmt+%subst string a = "\text{\tt " a "}"++\begin{code}+dir(include) "lhs2TeX.fmt"+\end{code}
+ doc/IncludeSyntax.lhs view
@@ -0,0 +1,5 @@+%include tex.fmt++\begin{code}+dir(include) ^^ ent(filename)+\end{code}
+ doc/Indent1.lhs view
@@ -0,0 +1,7 @@+%include poly.fmt++\begin{code}+unionBy           ::  (a -> a -> Bool) -> [a] -> [a] -> [a]+unionBy eq xs ys  =   xs ++ foldl  (flip (deleteBy eq))+                                   (nubBy eq ys)+\end{code}
+ doc/Indent1In.lhs view
@@ -0,0 +1,18 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" +%format \ = "\char''134"+%format let = "let"+%format in  = "in"+%format ->  = "->"+%format { = "{\origcolor{hcolor}" ( "}"+%format } = )+\begingroup+\let\origtt=\texfamily+\let\small\footnotesize+\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+\begin{code}+unionBy           ::  (a -> a -> Bool) -> [a] -> [a] -> [a]+unionBy eq xs ys  =   xs ++ foldl  {flip (deleteBy eq)}+                                   {nubBy eq ys}+\end{code}+\endgroup
+ doc/Indent2.lhs view
@@ -0,0 +1,7 @@+%include poly.fmt++\begin{code}+unionBy           ::  (a -> a -> Bool) -> [a] -> [a] -> [a]+unionBy eq xs ys  =   xs ++ foldl (flip (deleteBy eq))+                                  (nubBy eq ys)+\end{code}
+ doc/Indent2In.lhs view
@@ -0,0 +1,10 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt \makebox[0pt]{\phantom{X}}}+\begin{code}+unionBy           ::  (a -> a -> Bool) -> [a] -> [a] -> [a]+unionBy eq xs ys  =   xs ++ foldl (flip (deleteBy eq))+                                  (nubBy eq ys)+\end{code}+\endgroup
+ doc/Indent2a.lhs view
@@ -0,0 +1,14 @@+%include poly.fmt++\begin{code}+scanr1        ::  (a -> a -> a) -> [a] -> [a]+scanr1 f xxs  =   case xxs of+                     x:xs ->  case xs of+                                 []  ->  [x]+                                 _   ->  let +                                            qs = scanr1 f xs +                                         in+                                            case qs of +                                               q:_ -> f x q : qs++\end{code}
+ doc/Indent2aIn.lhs view
@@ -0,0 +1,27 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" +%format \ = "\char''134"+%format let = "let"+%format in  = "in"+%format case = "case"+%format of = "of"+%format ->  = "->"+%format { = "{\origcolor{hcolor}" ( "}"+%format } = )+\begingroup+\let\origtt=\texfamily+\let\small\footnotesize+\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+\begin{code}+scanr1        ::  (a -> a -> a) -> [a] -> [a]+scanr1 f xxs  =   case xxs of+                     x:xs ->  case xs of+                                 []  ->  [x]+                                 _   ->  let +                                            qs = scanr1 f xs +                                         in+                                            case qs of +                                               q:_ -> f x q : qs++\end{code}+\endgroup
+ doc/Indent3.lhs view
@@ -0,0 +1,9 @@+%include poly.fmt++%format foo = verylongfoo+\begin{code}+test  1+foo  bar+      2+\end{code}+
+ doc/Indent3In.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt \makebox[0pt]{\phantom{X}}}+>%format foo = verylongfoo+>\begin{code}+>test  1+>foo  bar+>      2+>\end{code}+\endgroup
+ doc/InlineTeXSyntax.lhs view
@@ -0,0 +1,10 @@+%include tex.fmt+\newcommand*{\InlineTeX}{@{-"@}%+\newcommand*{\EndInlineTeX}{@"-}@}%+%format inline(a) = "\InlineTeX " a "\EndInlineTeX "++\begin{code}+inline(ent(tex))+\end{code}+If this construct appears in a code block, then+|ent(tex)| is inserted literally into the output file.
+ doc/InstallationInstructions.lhs view
@@ -0,0 +1,14 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" ++\begingroup+\let\origtt=\texfamily+\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+%format ProgramVersion = "\ProgramVersion "+\begin{code}+$ cd /somewhere/lhs2TeX-ProgramVersion+$ ./configure+$ make+$ make install+\end{code}+\endgroup
+ doc/InteractiveGhci.lhs view
@@ -0,0 +1,17 @@+%include poly.fmt++%if False++> module InteractiveGhci where++%endif+%format . = "."+%format forall a = "\forall" a+%options ghci -fglasgow-exts++> fix    ::  forall a. (a -> a) -> a+> fix f  =   f (fix f)++This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.
+ doc/InteractiveGhciIn.lhs view
@@ -0,0 +1,22 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+%if False+module InteractiveGhci where+%endif+%format . = "."+%format forall a = "\forall" a++\begin{code}+%options ghci -fglasgow-exts++> fix    ::  forall a. (a -> a) -> a+> fix f  =   f (fix f)++This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.+\end{code}+\endgroup
+ doc/InteractiveHugs.lhs.in view
@@ -0,0 +1,27 @@+%include poly.fmt++%if False++> module InteractiveHugs where++%endif+%format . = "."+%format forall a = "\forall" a+%options hugs -98++> fix    ::  forall a. (a -> a) -> a+> fix f  =   f (fix f)++This function is of type +%if "@HUGS@" /= ""+\eval{:t fix},+%else+\textbf{?hugs not found?},+%endif+and |take 10 (fix ('x':))| +evaluates to+%if "@HUGS@" /= ""+\eval{take 10 (fix ('x':))}.+%else+\textbf{?hugs not found?}.+%endif
+ doc/InteractiveHugsIn.lhs view
@@ -0,0 +1,22 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+%if False+module InteractiveHugs where+%endif+%format . = "."+%format forall a = "\forall" a++\begin{code}+%options hugs -98++> fix    ::  forall a. (a -> a) -> a+> fix f  =   f (fix f)++This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.+\end{code}+\endgroup
+ doc/InteractivePre.lhs.in view
@@ -0,0 +1,24 @@+%include poly.fmt++%if style == newcode++> module InteractivePre where++%endif+%format SPL(x) = $ ( x )+%if style == newcode+%format QU(x)  = [ | x | ]+%format ^^     = " "+%else+%format QU(x)  = "\llbracket " x "\rrbracket "+%format ^^     = "\; "+%endif++%options ghci -fth -pgmL "@LHS2TEX@" -optL-Pdoc: -optL--pre++This is a rather stupid way of computing |42| using+Template Haskell:++> answer = SPL(foldr1 (\x y -> QU(SPL(x) + SPL(y))) (replicate 21 ^^ QU(2)))++The answer is indeed \eval{answer}.
+ doc/InteractivePreIn.lhs view
@@ -0,0 +1,31 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+%if style == newcode++module InteractivePre where++%endif++\begin{code}+%format SPL(x) = $ ( x )+%if style == newcode+%format QU(x)  = [ | x | ]+%format ^^     = " "+%else+%format QU(x)  = "\llbracket " x "\rrbracket "+%format ^^     = "\; "+%endif++%options ghci -fth -pgmL ../lhs2TeX -optL--pre++This is a rather stupid way of computing |42| using+Template Haskell:++> answer = SPL(foldr1 (\x y -> QU(SPL(x) + SPL(y))) (replicate 21 ^^ QU(2)))++The answer is indeed \eval{answer}.+\end{code}+\endgroup
+ doc/LetSyntax.lhs view
@@ -0,0 +1,24 @@+%include tex.fmt+\newcommand*{\amp}{@&&@}%+%format && = "\text{\amp}"+%format || = "\text{\ttfamily ||}"+%format == = "\text{\ttfamily ==}"+%format /= = "\text{\ttfamily /=}"+%format <  = "\text{\ttfamily <}"+%format <= = "\text{\ttfamily <=}"+%format >= = "\text{\ttfamily >=}"+%format >  = "\text{\ttfamily >}"+%format ++ = "\text{\ttfamily ++}"+%format +  = "\text{\ttfamily +}"+%format -  = "\text{\ttfamily -}"+%format *  = "\text{\ttfamily *}"+%format /  = "\text{\ttfamily /}"++\begin{code}+dir(^let^) ^^ ent(varname) ^^ syn(=) ^^ ent(expression)++ent(expression)   ::=  ent(application) ^^ many(ent(operator) ^^ ent(application))+ent(application)  ::=  opt(term(not)) ^^ ent(atom)+ent(atom)         ::=  ent(varid) | term(True) | term(False) | ent(string') | ent(numeral) | (ent(expression))+ent(operator)     ::=  && | || | == | /= | < | <= | >= | > | ++ | + | - | * | /+\end{code}
+ doc/Makefile view
@@ -0,0 +1,85 @@+include ../config.mk++# use in-place lhs2TeX+LHS2TEX = ../lhs2TeX++SNIPPETSGD  = $(shell $(GREP) "\\\\input{" Guide2.lhs | $(SED) "s/^.*input{\(.*\)}.*$$/\1.tex/")+ifdef STC+SNIPPETSSTC = $(shell $(GREP) "\\\\input{" STC.lhs | $(SED) "s/^.*input{\(.*\)}.*$$/\1.tex/")+SNIPPETSTLL = $(shell $(GREP) "\\\\input{" TLL.lhs | $(SED) "s/^.*input{\(.*\)}.*$$/\1.tex/")+STCFLAGS="--let=stc=True"+endif++SNIPPETSIN    = $(wildcard *.lhs.in)+SNIPPETSLHS   = $(filter-out $(SNIPPETSIN:.in=), $(SNIPPETSGD:.tex=.lhs))++DONTBUILD = $(shell test -f Guide2.dontbuild && echo yes)++# default target+ifeq ($(DONTBUILD),yes)+all : dontbuildwarning+else+all : Guide2.pdf+endif++# in-place polytable.sty+polytable.sty :+	$(LN_S) ../polytable/polytable.sty .+	$(LN_S) ../polytable/lazylist.sty .++RawSearchPath.lhs : ../Version.lhs+	echo '\begin{code}' > $@+	$(LHS2TEX) --searchpath >> $@+	echo '\end{code}' >> $@++SearchPath.lhs : RawSearchPath.lhs+	touch $@++srcdist :+	$(INSTALL) -m 644 $(SNIPPETSIN) ../$(DISTDIR)/doc+	$(INSTALL) -m 644 $(SNIPPETSLHS) ../$(DISTDIR)/doc+	$(INSTALL) -m 644 RawSearchPath.lhs ../$(DISTDIR)/doc+	$(INSTALL) -m 644 $(wildcard *.fmt) ../$(DISTDIR)/doc+	$(INSTALL) -m 644 Guide2.lhs Guide2.pdf Makefile ../$(DISTDIR)/doc+	$(INSTALL) -m 755 lhs2TeXpre ../$(DISTDIR)/doc+	touch ../$(DISTDIR)/doc/Guide2.dontbuild++dontbuildwarning :+	echo "----------------------------------------------"; \+	echo "To rebuild Guide2.pdf, remove Guide2.dontbuild"; \+	echo "and call make again."; \+	echo "----------------------------------------------"; \++%.pdf : %.tex polytable.sty+	$(SHELL) -c ' \+		$(PDFLATEX) $(PDFLATEX_OPTS) $<; \+		while $(GREP) -c "Warning.*Rerun" $(<:.tex=.log); \+			do $(PDFLATEX) $(PDFLATEX_OPTS) $<; done;'; \++Guide2.tex : Guide2.lhs $(SNIPPETSGD)+	$(LHS2TEX) --poly -P.:.. $< > $@++STC.tex : STC.lhs $(SNIPPETSSTC)+	$(LHS2TEX) --poly $< > $@++TLL.tex : TLL.lhs $(SNIPPETSTLL)+	$(LHS2TEX) --poly $< > $@++# determine mode and then run lhs2TeX+%.tex : %.lhs+	MODE=`cat $< \+		| $(GREP) "^%include" \+		| head -n 1 \+		| $(SED) -e "s/^%include \(.*\)\.fmt/\1/" \+		| $(SED) -e "s/verbatim/verb/" \+			 -e "s/stupid/math/" \+		      	 -e "s/tex/poly/" \+		      	 -e "s/polytt/poly/" \+		      	 -e "s/typewriter/tt/"` && \+	echo $${MODE} && \+	$(LHS2TEX) --$${MODE} $(STCFLAGS) $< > $@++.PHONY : all srcdist clean+clean :+	rm -f $(SNIPPETSGD) $(SNIPPETSSTC)+
+ doc/MkTeXLsrCall.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+$ mktexlsr+\end{code}+\endgroup
+ doc/ParensExample.lhs view
@@ -0,0 +1,15 @@+%include poly.fmt++\begingroup+\setlength{\abovedisplayskip}{1pt}+\setlength{\belowdisplayskip}{1pt}++%format ^^                = "\;"+%format (ptest (a) b (c)) = ptest ^^ a ^^ b ^^ c+\begin{code}+ptest a b c+(ptest (a) (b) (c))+((ptest((a)) ((b)) ((c))))+\end{code}++\endgroup
+ doc/ParensExample2.lhs view
@@ -0,0 +1,16 @@+%include poly.fmt++\begingroup+\setlength{\abovedisplayskip}{1pt}+\setlength{\belowdisplayskip}{1pt}++%format eval a = "\llbracket " a "\rrbracket "+\begin{code}+size (eval (2 + 2)) +\end{code}+%format (eval (a)) = "\llbracket " a "\rrbracket "+\begin{code}+size (eval (2 + 2)) +\end{code}++\endgroup
+ doc/ParensExample2In.lhs view
@@ -0,0 +1,13 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>%format eval a = "\llbracket " a "\rrbracket "+>\begin{code}+>size (eval (2 + 2)) +>\end{code}+>%format (eval (a)) = "\llbracket " a "\rrbracket "+>\begin{code}+>size (eval (2 + 2)) +>\end{code}+\endgroup
+ doc/ParensExampleIn.lhs view
@@ -0,0 +1,12 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>%format ^^                = "\;"+>%format (ptest (a) b (c)) = ptest ^^ a ^^ b ^^ c+>\begin{code}+>ptest a b c+>(ptest (a) (b) (c))+>((ptest((a)) ((b)) ((c))))+>\end{code}+\endgroup
+ doc/PlusDefinition.lhs view
@@ -0,0 +1,8 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\newcommand{\plus}{\mathbin{+\!\!\!+}}++\endgroup
+ doc/RawSearchPath.lhs view
@@ -0,0 +1,25 @@+\begin{code}+.+{HOME}/lhs2tex-1.12//+{HOME}/lhs2tex//+{HOME}/lhs2TeX//+{HOME}/.lhs2tex-1.12//+{HOME}/.lhs2tex//+{HOME}/.lhs2TeX//+{LHS2TEX}//+/usr/local/share/lhs2tex-1.12//+/usr/local/share/lhs2tex-1.12//+/usr/local/lib/lhs2tex-1.12//+/usr/share/lhs2tex-1.12//+/usr/lib/lhs2tex-1.12//+/usr/local/share/lhs2tex//+/usr/local/share/lhs2tex//+/usr/local/lib/lhs2tex//+/usr/share/lhs2tex//+/usr/lib/lhs2tex//+/usr/local/share/lhs2TeX//+/usr/local/share/lhs2TeX//+/usr/local/lib/lhs2TeX//+/usr/share/lhs2TeX//+/usr/lib/lhs2TeX//+\end{code}
+ doc/RepAlg.lhs view
@@ -0,0 +1,8 @@+%include poly.fmt++> rep_alg         =  (\  _          -> \m ->  Leaf m+>                    ,\  lfun rfun  -> \m ->  let  lt  = lfun m+>                                                  rt  = rfun m+>                                             in   Bin lt rt+>                    )+> replace_min' t  =  (cata_Tree rep_alg t) (cata_Tree min_alg t)
+ doc/RepAlgIn.lhs view
@@ -0,0 +1,19 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" +%format \ = "\char''134"+%format let = "let"+%format in  = "in"+%format ->  = "->"+%format !=  = "{\origcolor{hcolor}" = "}"+%format llt = "{\origcolor{hcolor}" lt "}"+\begingroup+\let\origtt=\texfamily+\let\small\footnotesize+\def\texfamily#1{\origtt}+>> rep_alg         =  (\  _          -> \m ->  Leaf m+>>                    ,\  lfun rfun  -> \m ->  let  lt  != lfun m+>>                                                  rt  != rfun m+>>                                             in   Bin llt rt+>>                    )+>> replace_min' t  =  (cata_Tree rep_alg t) (cata_Tree min_alg t)+\endgroup
+ doc/SaveRestore.lhs view
@@ -0,0 +1,17 @@+%include poly.fmt++\begingroup++\savecolumns+\begin{code}+intersperse               ::  a -> [a] -> [a]+intersperse  _    []      =   []+intersperse  _    [x]     =   [x]+\end{code}+The only really interesting case is the one for lists +containing at least two elements:+\restorecolumns+\begin{code}+intersperse  sep  (x:xs)  =   x : sep : intersperse sep xs+\end{code}+\endgroup
+ doc/SaveRestoreIn.lhs view
@@ -0,0 +1,18 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}+>\savecolumns+>\begin{code}+>intersperse               ::  a -> [a] -> [a]+>intersperse  _    []      =   []+>intersperse  _    [x]     =   [x]+>\end{code}+>The only really interesting case is the one for lists +>containing at least two elements:+>\restorecolumns+>\begin{code}+>intersperse  sep  (x:xs)  =   x : sep : intersperse sep xs+>\end{code}+\endgroup
+ doc/SaveRestoreNo.lhs view
@@ -0,0 +1,15 @@+%include poly.fmt++\begingroup++\begin{code}+intersperse               ::  a -> [a] -> [a]+intersperse  _    []      =   []+intersperse  _    [x]     =   [x]+\end{code}+The only really interesting case is the one for lists +containing at least two elements:+\begin{code}+intersperse  sep  (x:xs)  =   x : sep : intersperse sep xs+\end{code}+\endgroup
+ doc/SearchPath.lhs view
@@ -0,0 +1,6 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+%include RawSearchPath.lhs+\endgroup
+ doc/SepLatSyntax.lhs view
@@ -0,0 +1,6 @@+%include tex.fmt++\begin{code}+dir(separation) ^^ ent(natural)+dir(latency) ^^ ent(natural)+\end{code}
+ doc/SpacingOps.lhs view
@@ -0,0 +1,10 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+%format ^  = " "+%format ^^ = "\;"+\end{code}+\endgroup
+ doc/SpacingOpsCond.lhs view
@@ -0,0 +1,15 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt}+\begin{code}+%if style == newcode+%format ^  =+%format ^^ = " "+%else+%format ^  = " "+%format ^^ = "\;"+%endif+\end{code}+\endgroup
+ doc/Variable.lhs view
@@ -0,0 +1,6 @@+%include poly.fmt++%format test = style+\begin{code}+test+\end{code}
+ doc/Zip.lhs view
@@ -0,0 +1,19 @@+%include verbatim.fmt++\begingroup+\let\origtt=\tt+\def\tt#1{\origtt\makebox[0pt]{\phantom{X}}}+\begin{code}+zip                     :: [a] -> [b] -> [(a,b)]+zip                     =  zipWith  (\a b -> (a,b))++zipWith                 :: (a->b->c) -> [a]->[b]->[c]+zipWith z (a:as) (b:bs) =  z a b : zipWith z as bs+zipWith _ _      _      =  []++partition               :: (a -> Bool) -> [a] -> ([a],[a])+partition p xs          =  foldr select ([],[]) xs+   where select x (ts,fs) | p x       = (x:ts,fs)+                          | otherwise = (ts,x:fs)+\end{code}+\endgroup
+ doc/ZipMath.lhs view
@@ -0,0 +1,20 @@+%let array=True+%include stupid.fmt+%subst code a = "\begin{colorarray}{@{}lcl@{}}'n" a "\end{colorarray}'n" ++%align 28+\begin{code}+zip                        :: [a] -> [b] -> [(a,b)]+zip                        =  zipWith  (\a b -> (a,b))++zipWith                    :: (a->b->c) -> [a]->[b]->[c]+zipWith z (a:as) (b:bs)    =  z a b : zipWith z as bs+zipWith _ _      _         =  []++partition                  :: (a -> Bool) -> [a] -> ([a],[a])+partition p xs             =  foldr select ([],[]) xs+   where select x (ts,fs) | p x       = (x:ts,fs)+                          | otherwise = (ts,x:fs)+\end{code}++
+ doc/ZipPoly.lhs view
@@ -0,0 +1,16 @@+%include poly.fmt+%subst code a = "\begin{colorcode}'n" a "\end{colorcode}\resethooks'n" ++\begin{code}+zip                        ::  [a] -> [b] -> [(a,b)]+zip                        =   zipWith  (\a b -> (a,b))++zipWith                    ::  (a->b->c) -> [a]->[b]->[c]+zipWith z  (a:as)  (b:bs)  =   z a b : zipWith z as bs+zipWith _  _       _       =   []++partition                  ::  (a -> Bool) -> [a] -> ([a],[a])+partition p xs             =   foldr select ([],[]) xs+   where select x (ts,fs)    |  p x        =  (x:ts,fs)+                             |  otherwise  =  (ts,x:fs)+\end{code}
+ doc/ZipPolyTT.lhs view
@@ -0,0 +1,16 @@+%include polytt.fmt+%subst code a = "\begin{colorcode}\thinmuskip=10mu\medmuskip=10mu\thickmuskip=10mu\relax'n" a "\end{colorcode}\resethooks'n" ++\begin{code}+zip                        ::  [a] -> [b] -> [(a,b)]+zip                        =   zipWith  (\a b -> (a,b))++zipWith                    ::  (a->b->c) -> [a]->[b]->[c]+zipWith z  (a:as)  (b:bs)  =   z a b : zipWith z as bs+zipWith _  _       _       =   []++partition                  ::  (a -> Bool) -> [a] -> ([a],[a])+partition p xs             =   foldr select ([],[]) xs+   where select x (ts,fs)    |  p x        =  (x:ts,fs)+                             |  otherwise  =  (ts,x:fs)+\end{code}
+ doc/ZipStupid.lhs view
@@ -0,0 +1,20 @@+%let array=True+%include stupid.fmt+%subst code a = "\begin{colorarray}{@{}lcl@{}}'n" a "\end{colorarray}'n" ++%align 99+\begin{code}+zip                     :: [a] -> [b] -> [(a,b)]+zip                     =  zipWith  (\a b -> (a,b))++zipWith                 :: (a->b->c) -> [a]->[b]->[c]+zipWith z (a:as) (b:bs) =  z a b : zipWith z as bs+zipWith _ _      _      =  []++partition               :: (a -> Bool) -> [a] -> ([a],[a])+partition p xs          =  foldr select ([],[]) xs+   where select x (ts,fs) | p x       = (x:ts,fs)+                          | otherwise = (ts,x:fs)+\end{code}++
+ doc/ZipTT.lhs view
@@ -0,0 +1,20 @@+%include typewriter.fmt+%subst code a = "\begin{colorverb}'n\texfamily " a "\end{colorverb}'n" ++\begingroup+\let\origtt=\texfamily+\def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+\begin{code}+zip                     :: [a] -> [b] -> [(a,b)]+zip                     =  zipWith  (\a b -> (a,b))++zipWith                 :: (a->b->c) -> [a]->[b]->[c]+zipWith z (a:as) (b:bs) =  z a b : zipWith z as bs+zipWith _ _      _      =  []++partition               :: (a -> Bool) -> [a] -> ([a],[a])+partition p xs          =  foldr select ([],[]) xs+   where select x (ts,fs) | p x       = (x:ts,fs)+                          | otherwise = (ts,x:fs)+\end{code}+\endgroup
+ doc/lhs2TeXpre view
@@ -0,0 +1,18 @@+#! /bin/sh++# wrapper for use with GHC/GHCi+# -pgmF lhs2TeXpre -F++LHSHOME=..++if [ "$1" == "$2" ]; then+  cp "$2" "$3"+else+  if grep -q "^%include" "$1"; then+    TARGET=$3+    # echo Calling with TARGET=${TARGET}+    ${LHSHOME}/lhs2TeX --newcode -P${LHSHOME}: $1 > ${TARGET}+  else+    cp "$2" "$3"+  fi+fi
+ doc/poly.fmt view
@@ -0,0 +1,380 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%format \               = "\"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\>[" b "]{}" t "{}\<[" e "]"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\\'n"+%subst blankline        = "\\[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif+%if style /= newcode+%subst code a = "\begin{colorcode}'n" a "\end{colorcode}\resethooks'n" +%endif
+ doc/polytt.fmt view
@@ -0,0 +1,359 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\fromto{" b "}{" e "}{{}" t "{}}'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\nextline'n"+%subst blankline        = "\nextline[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= +%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= a+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= a+%subst keyword a 	= "\text{\texfamily\itshape{" a "}}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\mskip\thickmuskip"+%subst conid a   	= "\text{\texfamily\origcolor{hcolor}{" a "}}"+%subst varid a   	= "\text{\texfamily " a "}"+%subst consym a  	= "\text{\texfamily " a "}"+%subst varsym a  	= "\text{\texfamily " a "}"+%subst char a    	= "\text{\texfamily ''" a "''}"+%subst string a  	= "\text{\texfamily \char34 " a "\char34}"+%format [         = "\mathopen{\text{\texfamily [}}"+%format ]         = "\mathclose{\text{\texfamily ]}}"+%format (         = "\mathopen{\text{\texfamily (}}"+%format )         = "\mathclose{\text{\texfamily )}}"+%format ,         = "\mathpunct{\text{\texfamily ,}}"+%format ::        = "\mathrel{\text{\texfamily ::}}"+%format :         = "\mathop{\text{\texfamily :}}"+%format \         = "\text{\texfamily\char''10}"+%format =         = "\mathrel{\text{\texfamily =}}"+%format |         = "\mathrel{\text{\texfamily |}}"+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\mathbin{\text{\texfamily\char''04}}"+%format ||        = "\mathbin{\text{\texfamily\char''37}}"+%format <-        = "\mathbin{\text{\texfamily\char''06}}"+%format ->        = "\mathbin{\text{\texfamily\char''31}}"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif
+ doc/stupid.fmt view
@@ -0,0 +1,376 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\fromto{" b "}{" e "}{{}" t "{}}'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\nextline'n"+%subst blankline        = "\nextline[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif
+ doc/tex.fmt view
@@ -0,0 +1,411 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\fromto{" b "}{" e "}{{}" t "{}}'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\nextline'n"+%subst blankline        = "\nextline[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif+%subst code a = "\begin{colorcode}'n" a "\end{colorcode}\resethooks'n" +%subst keyword a = "\keyw{" a "}"++%if False+%format dir(a) = "\text{\textbf{\%}}{\let\Varid\mathbf " a "}"+%else+%format dir(a) = "\text{\texttt{\%}}{\let\Varid\mathtt " a "}"+%format =      = "\mathrel{\text{\texttt{=}}}"+%format term(a) = "{\let\Varid\mathtt\let\Conid\mathtt " a "}"+\let\keyw=\mathtt+%endif++%format not    = "\Varid{not}"++%format ent(a) = "{\langle " a "\rangle}"+%format syn(a) = "{" a "}"++%format many(a) = "{" a "}^{*}"+%format manyp(a) = "{(" a ")}^{*}"+%format opt(a) = "{" a "}?"+%format string(a) = "\mathopen{\text{\texfamily\char34}}" a "\mathclose{\text{\texfamily\char34}}"+%format string' = "\Varid{string}"+%format back(a) = "\mathopen{\text{\texfamily`}}" a "\mathclose{\text{\texfamily`}}"++%format ( = "\mathopen{\text{\texfamily(}}"+%format ) = "\mathclose{\text{\texfamily)}}"+%format { = "\mathopen{\text{\texfamily\char''173 }}"+%format } = "\mathclose{\text{\texfamily\char''175 }}"+%format ^^^ = "\qquad "+%format ^^ = "\;"+%format ^  = " "++%format ::= = "\mathrel{::=}"++%format (test (a) (b)) = "-" a "-" b "-"
+ doc/typewriter.fmt view
@@ -0,0 +1,380 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{" a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%if color+%subst keyword a = "{\origcolor{red} " a "}"+%else+%subst keyword a = "{\itshape " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\fromto{" b "}{" e "}{{}" t "{}}'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\nextline'n"+%subst blankline        = "\nextline[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif+%endif
+ doc/verbatim.fmt view
@@ -0,0 +1,378 @@+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+%format #               = "#"+%format $               = "$"+%format %               = "%"+%format &               = "&"+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\fromto{" b "}{" e "}{{}" t "{}}'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\nextline'n"+%subst blankline        = "\nextline[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+%if meta+%format M.a = "a"+%format M.b = "b"+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif++%subst verbatim a = "\begin{colorverb}'n\tt " a "\end{colorverb}'n" 
+ id.snip view
@@ -0,0 +1,7 @@+%format (MkId a) = a++> newtype Id a                  =  MkId a+> instance Monad Id where+>     return a                  =  MkId a+>     MkId a >>= f              =  f a {-""-}+>     MkId a >>= f              =  f a
+ install-sh view
@@ -0,0 +1,251 @@+#!/bin/sh+#+# install - install a program, script, or datafile+# This comes from X11R5 (mit/util/scripts/install.sh).+#+# Copyright 1991 by the Massachusetts Institute of Technology+#+# Permission to use, copy, modify, distribute, and sell this software and its+# documentation for any purpose is hereby granted without fee, provided that+# the above copyright notice appear in all copies and that both that+# copyright notice and this permission notice appear in supporting+# documentation, and that the name of M.I.T. not be used in advertising or+# publicity pertaining to distribution of the software without specific,+# written prior permission.  M.I.T. makes no representations about the+# suitability of this software for any purpose.  It is provided "as is"+# without express or implied warranty.+#+# Calling this script install-sh is preferred over install.sh, to prevent+# `make' implicit rules from creating a file called install from it+# when there is no Makefile.+#+# This script is compatible with the BSD install script, but was written+# from scratch.  It can only install one file at a time, a restriction+# shared with many OS's install programs.+++# set DOITPROG to echo to test this script++# Don't use :- since 4.3BSD and earlier shells don't like it.+doit="${DOITPROG-}"+++# put in absolute paths if you don't have them in your path; or use env. vars.++mvprog="${MVPROG-mv}"+cpprog="${CPPROG-cp}"+chmodprog="${CHMODPROG-chmod}"+chownprog="${CHOWNPROG-chown}"+chgrpprog="${CHGRPPROG-chgrp}"+stripprog="${STRIPPROG-strip}"+rmprog="${RMPROG-rm}"+mkdirprog="${MKDIRPROG-mkdir}"++transformbasename=""+transform_arg=""+instcmd="$mvprog"+chmodcmd="$chmodprog 0755"+chowncmd=""+chgrpcmd=""+stripcmd=""+rmcmd="$rmprog -f"+mvcmd="$mvprog"+src=""+dst=""+dir_arg=""++while [ x"$1" != x ]; do+    case $1 in+	-c) instcmd="$cpprog"+	    shift+	    continue;;++	-d) dir_arg=true+	    shift+	    continue;;++	-m) chmodcmd="$chmodprog $2"+	    shift+	    shift+	    continue;;++	-o) chowncmd="$chownprog $2"+	    shift+	    shift+	    continue;;++	-g) chgrpcmd="$chgrpprog $2"+	    shift+	    shift+	    continue;;++	-s) stripcmd="$stripprog"+	    shift+	    continue;;++	-t=*) transformarg=`echo $1 | sed 's/-t=//'`+	    shift+	    continue;;++	-b=*) transformbasename=`echo $1 | sed 's/-b=//'`+	    shift+	    continue;;++	*)  if [ x"$src" = x ]+	    then+		src=$1+	    else+		# this colon is to work around a 386BSD /bin/sh bug+		:+		dst=$1+	    fi+	    shift+	    continue;;+    esac+done++if [ x"$src" = x ]+then+	echo "install:	no input file specified"+	exit 1+else+	true+fi++if [ x"$dir_arg" != x ]; then+	dst=$src+	src=""+	+	if [ -d $dst ]; then+		instcmd=:+		chmodcmd=""+	else+		instcmd=mkdir+	fi+else++# Waiting for this to be detected by the "$instcmd $src $dsttmp" command+# might cause directories to be created, which would be especially bad +# if $src (and thus $dsttmp) contains '*'.++	if [ -f $src -o -d $src ]+	then+		true+	else+		echo "install:  $src does not exist"+		exit 1+	fi+	+	if [ x"$dst" = x ]+	then+		echo "install:	no destination specified"+		exit 1+	else+		true+	fi++# If destination is a directory, append the input filename; if your system+# does not like double slashes in filenames, you may need to add some logic++	if [ -d $dst ]+	then+		dst="$dst"/`basename $src`+	else+		true+	fi+fi++## this sed command emulates the dirname command+dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`++# Make sure that the destination directory exists.+#  this part is taken from Noah Friedman's mkinstalldirs script++# Skip lots of stat calls in the usual case.+if [ ! -d "$dstdir" ]; then+defaultIFS='	+'+IFS="${IFS-${defaultIFS}}"++oIFS="${IFS}"+# Some sh's can't handle IFS=/ for some reason.+IFS='%'+set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`+IFS="${oIFS}"++pathcomp=''++while [ $# -ne 0 ] ; do+	pathcomp="${pathcomp}${1}"+	shift++	if [ ! -d "${pathcomp}" ] ;+        then+		$mkdirprog "${pathcomp}"+	else+		true+	fi++	pathcomp="${pathcomp}/"+done+fi++if [ x"$dir_arg" != x ]+then+	$doit $instcmd $dst &&++	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi+else++# If we're going to rename the final executable, determine the name now.++	if [ x"$transformarg" = x ] +	then+		dstfile=`basename $dst`+	else+		dstfile=`basename $dst $transformbasename | +			sed $transformarg`$transformbasename+	fi++# don't allow the sed command to completely eliminate the filename++	if [ x"$dstfile" = x ] +	then+		dstfile=`basename $dst`+	else+		true+	fi++# Make a temp file name in the proper directory.++	dsttmp=$dstdir/#inst.$$#++# Move or copy the file name to the temp name++	$doit $instcmd $src $dsttmp &&++	trap "rm -f ${dsttmp}" 0 &&++# and set any options; do chmod last to preserve setuid bits++# If any of these fail, we abort the whole thing.  If we want to+# ignore errors from any of these, just make sure not to ignore+# errors from the above "$doit $instcmd $src $dsttmp" command.++	if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&+	if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&+	if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&+	if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&++# Now rename the file to the real destination.++	$doit $rmcmd -f $dstdir/$dstfile &&+	$doit $mvcmd $dsttmp $dstdir/$dstfile ++fi &&+++exit 0
+ lhs2TeX.1.in view
@@ -0,0 +1,228 @@+.TH LHS2TEX "1" "January 2006" "lhs2TeX" "User Commands"+.SH NAME+lhs2TeX \- a literate Haskell to (La)TeX code translator++.SH SYNOPSIS+.B lhs2TeX+[options]+file++.SH DESCRIPTION+This tool takes as its input a literate Haskell source+file (Bird-style or LaTeX-style or even a combination thereof),+and produces output, which, depending on the+.B STYLE+selected, can be either a LaTeX document or a stripped version+of the code. +The output is produced on stdout.+Several directives are interpreted by+.B lhs2TeX+itself and can be used to customize the output further.++.SH OPTIONS+There are two sorts of options for +\fBlhs2TeX\fR. The first selects a+.B STYLE+which governs the overal mode of operation for +\fBlhs2TeX\fR. Only one style may be selected:+++.TP+.B --poly+The poly style is an improvement of the older+.B math+style. It produces a LaTeX document, with the code blocks+formatted using a proportional font. The output is highly customizable+using formatting directives. Furthermore, the resulting code+respects some of the alignments made in the source file.++.TP+.B --math+The math style is as+.B poly+style, but has less alignment capabilities. Tokens appearing in the+source file at a special column are all aligned in the+output. Furthermore, indentation is respected.++.TP+.B --newcode+In the new code style, everything but code blocks is stripped from+the file. In addition, certain syntactic transformations can be+performed on the code using formatting directives. For example, if+the source code is annotated in certain positions to produce even+nicer results in+.B poly+style, one can use+.B newcode+style to remove these annotations.++.TP+.B --code+In code style, all comments and specification code is stripped from+the file, so that only the code remains. Use this if you want to+produce a smaller version of your source file.++.TP+.B --tt+Typewriter style prints code almost verbatim, using a monospaced font,+but formatting certain symbols (lambda abstraction, arrows ...) using+an extended character set. This style is default if no style is+explicitly selected, but this behaviour should not be relied upon.+The default style may be changed in future versions.++.TP+.B --verb+Verbatim style prints code as-is, using a monospaced font. No+formatting whatsoever is applied to the code. However,+.B lhs2TeX+does not make use of a LaTeX verbatim environment, but rather+escapes special TeX constructs in the translation. This implies that+it is easier to pass the resulting TeX code to macros or use it+inside certain environments than it would be with a native+verbatim-environment.++.PD+.PP+The following options are considered are also considered as styles,+but return only information about the program:++.TP+\fB-h\fR, \fB-?\fR, \fB--help\fR+Returns a short usage message listing all the available options.++.TP+\fB-V\fR, \fB--version\fR+Returns version information. ++.TP+.B --copying+Displays the complete GNU General Public License.++.TP+.B --warranty+Displays the parts of the GPL than concerns warranty.++.PD+.PP+The remaining options modify the behaviour of the program.++.TP+\fB-P\fIpath\fR, \fB--path=\fIpath\fR+Takes a (colon-separated) list+.I path+of paths that are used+as search path for files to be included. If the list starts+with a colon, then the list is appended to the current+search path. If the list ends with a colon, then the list+is prepended to the current search path. If there is neither+a colon at the beginning nor at the end of the list, then+the list replaces the current search path. ++Environment+variables can be used in the list of paths, if enclosed+in curly braces, i.e.,+.I {VAR}+expands to the current value of the environment variable+VAR. If a path ends with a double slash +\fI//\fR, then all subdirectories+of that path are included in the search path. Note that this+can significantly slow down+.B lhs2TeX+when looking for files.++The built-in default search path of+.B lhs2TeX+is++.nf+   {HOME}/lhs2TeX//+   {HOME}/.lhs2TeX//+   {LHS2TEX}//+   /usr/local/share/lhs2tex//+   /usr/local/share/lhs2TeX//+   /usr/local/lib/lhs2tex//+   /usr/local/lib/lhs2TeX//+   /usr/share/lhs2tex//+   /usr/share/lhs2TeX//+   /usr/lib/lhs2tex//+   /usr/lib/lhs2TeX//+.fi++.TP+\fB-i\fIfile\fR, \fB--include=\fIfile\fR+Includes+.I file+before anything else. This option has the same effect+as an++.nf+   %include \fIfile\fR+.fi++directive at the beginning of the source file.++.TP+\fB-l\fIequation\fR, \fB--let=\fIequation\fR+Assumes+.I equation+while processing the source file. This option has the+same effect as a++.nf+   %let \fIequation\fR+.fi++directive at the beginning of the source file.++.TP+\fB-s\fIflag\fR, \fB--set=\fIflag\fR+Sets+.I flag+to+.B True+at the beginning of the source file. This option has+the same effect as a++.nf+   %let \fIflag\fR=True+.fi++at the beginning of the source file.++.TP+\fB-u\fIflag\fR, \fB--unset=\fIflag\fR+Sets+.I flag+to+.B False+at the beginning of the source file. This option has+the same effect as a++.nf+   %let \fIflag\fR=False+.fi++at the beginning of the source file.++.SH VERSION+@VERSION@++.SH AUTHORS+Andres Loeh <polytable at andres-loeh dot de> wrote+.B poly +and+.B newcode+styles and is the current maintainer of the package.++Ralf Hinze <ralf at informatik dot uni-bonn dot de> wrote+the original+.BR lhs2TeX .++.SH SEE ALSO+.IR http://www.informatik.uni-bonn.de/~loeh/lhs2tex ,+the +.B lhs2TeX +homepage+.br+.IR Guide2.pdf ,+the manual
+ lhs2TeX.fmt.lit view
@@ -0,0 +1,478 @@+\begin{code}+%if False+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+%endif+%if not lhs2tex_lhs2tex_fmt_read+%let lhs2tex_lhs2tex_fmt_read = True+\end{code}++%-------------------------------=  --------------------------------------------+\section{Format definitions}+%-------------------------------=  --------------------------------------------++%-------------------------------=  --------------------------------------------+\subsection{Verbatim style}+%-------------------------------=  --------------------------------------------++Also used for \verb@\verb@ and \verb@\begin{verbatim}@, so no+conditionals at work here.+%+\begin{code}+%subst verb a		= "\text{\tt " a "}"+%subst verbatim a	= "\begin{tabbing}\tt'n" a "'n\end{tabbing}'n"+%subst verbnl		= "\\'n\tt "+\end{code}++%-------------------------------=  --------------------------------------------+\subsection{Typewriter style}+%-------------------------------=  --------------------------------------------++\begin{code}+%if style == tt+%subst inline a  = "\text{\texfamily " a "}"+%subst thinspace = "\Sp "+%subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n"+%subst comment a = "{\rmfamily-{}- " a "}"+%subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}"+%subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst spaces a  = a+%subst special a = a+%subst space     = "~"+%subst newline   = "\\'n\texfamily "+%subst conid a   = "{\itshape " a "}"+%subst varid a   = a+%subst consym a  = a+%subst varsym a  = a+%subst numeral a = a+%subst char a    = "''" a "''"+%subst string a  = "\char34 " a "\char34 "+%if underlineKeywords+%subst keyword a = "\uline{" a "}"+%else+%subst keyword a = "{\bfseries " a "}"+%endif+%format \         = "\char''10"+%format .         = "\char''00"+%if not spacePreserving+%format alpha     = "\char''02"+%format beta      = "\char''03"+%format gamma     = "\char''11"+%format delta     = "\char''12"+%format pi        = "\char''07"+%format infty     = "\char''16"+%format intersect = "\char''22"+%format union     = "\char''23"+%format forall    = "\char''24"+%format exists    = "\char''25"+%format not       = "\char''05"+%format &&        = "\char''04"+%format ||        = "\char''37"+%format <-        = "\char''06"+%format ->        = "\char''31"+%format ==        = "\char''36"+%format /=        = "\char''32"+%format <=        = "\char''34"+%format >=        = "\char''35"+%endif+\end{code}+%+Unterst"utzung f"ur Meta-Haskell.+%+\begin{code}+%if meta+%format M.a = "\ensuremath{a}"+%format M.b = "\ensuremath{b}"+\end{code}+etc~(for all lower and upper case letters).+%if style == code+\begin{code}+%format M.c = "\ensuremath{c}"+%format M.d = "\ensuremath{d}"+%format M.e = "\ensuremath{e}"+%format M.f = "\ensuremath{f}"+%format M.g = "\ensuremath{g}"+%format M.h = "\ensuremath{h}"+%format M.i = "\ensuremath{i}"+%format M.j = "\ensuremath{j}"+%format M.k = "\ensuremath{k}"+%format M.l = "\ensuremath{l}"+%format M.m = "\ensuremath{m}"+%format M.n = "\ensuremath{n}"+%format M.o = "\ensuremath{o}"+%format M.p = "\ensuremath{p}"+%format M.q = "\ensuremath{q}"+%format M.r = "\ensuremath{r}"+%format M.s = "\ensuremath{s}"+%format M.t = "\ensuremath{t}"+%format M.u = "\ensuremath{u}"+%format M.v = "\ensuremath{v}"+%format M.w = "\ensuremath{w}"+%format M.x = "\ensuremath{x}"+%format M.y = "\ensuremath{y}"+%format M.z = "\ensuremath{z}"+%format M.A = "\ensuremath{A}"+%format M.B = "\ensuremath{B}"+%format M.C = "\ensuremath{C}"+%format M.D = "\ensuremath{D}"+%format M.E = "\ensuremath{E}"+%format M.F = "\ensuremath{F}"+%format M.G = "\ensuremath{G}"+%format M.H = "\ensuremath{H}"+%format M.I = "\ensuremath{I}"+%format M.J = "\ensuremath{J}"+%format M.K = "\ensuremath{K}"+%format M.L = "\ensuremath{L}"+%format M.M = "\ensuremath{M}"+%format M.N = "\ensuremath{N}"+%format M.O = "\ensuremath{O}"+%format M.P = "\ensuremath{P}"+%format M.Q = "\ensuremath{Q}"+%format M.R = "\ensuremath{R}"+%format M.S = "\ensuremath{S}"+%format M.T = "\ensuremath{T}"+%format M.U = "\ensuremath{U}"+%format M.V = "\ensuremath{V}"+%format M.W = "\ensuremath{W}"+%format M.X = "\ensuremath{X}"+%format M.Y = "\ensuremath{Y}"+%format M.Z = "\ensuremath{Z}"+\end{code}+%endif+\begin{code}+%format M.alpha   = "\ensuremath{\alpha}"+%format M.beta    = "\ensuremath{\beta}"+\end{code}+etc~(for all lower and upper case greek letters).+%if style == code+\begin{code}+%format M.gamma   = "\ensuremath{\gamma}"+%format M.delta   = "\ensuremath{\delta}"+%format M.epsilon = "\ensuremath{\epsilon}"+%format M.zeta    = "\ensuremath{\zeta}"+%format M.eta     = "\ensuremath{\eta}"+%format M.theta   = "\ensuremath{\theta}"+%format M.iota    = "\ensuremath{\iota}"+%format M.kappa   = "\ensuremath{\kappa}"+%format M.lambda  = "\ensuremath{\lambda}"+%format M.mu      = "\ensuremath{\mu}"+%format M.nu      = "\ensuremath{\nu}"+%format M.xi      = "\ensuremath{\xi}"+%format M.pi      = "\ensuremath{\pi}"+%format M.rho     = "\ensuremath{\rho}"+%format M.sigma   = "\ensuremath{\sigma}"+%format M.tau     = "\ensuremath{\tau}"+%format M.upsilon = "\ensuremath{\upsilon}"+%format M.phi     = "\ensuremath{\phi}"+%format M.chi     = "\ensuremath{\chi}"+%format M.psi     = "\ensuremath{\psi}"+%format M.omega   = "\ensuremath{\omega}"+%format M.Gamma   = "\ensuremath{\Gamma}"+%format M.Delta   = "\ensuremath{\Delta}"+%format M.Theta   = "\ensuremath{\Theta}"+%format M.Lambda  = "\ensuremath{\Lambda}"+%format M.Xi      = "\ensuremath{\Xi}"+%format M.Pi      = "\ensuremath{\Pi}"+%format M.Sigma   = "\ensuremath{\Sigma}"+%format M.Upsilon = "\ensuremath{\Upsilon}"+%format M.Phi     = "\ensuremath{\Phi}"+%format M.Psi     = "\ensuremath{\Psi}"+%format M.Omega   = "\ensuremath{\Omega}"+\end{code}+%endif+\begin{code}+%format M.forall  = "\ensuremath{\forall}"+%format M.exists  = "\ensuremath{\exists}"+%format M.not     = "\ensuremath{\neg}"+%format ==>       = "\ensuremath{\Longrightarrow}"+%format <==       = "\ensuremath{\Longleftarrow}"+%format /\        = "\ensuremath{\wedge}"+%format \/        = "\ensuremath{\vee}"+%format M.=       = "\ensuremath{=}"+%format M./=      = "\ensuremath{\neq}"+%format M.<       = "\ensuremath{<}"+%format M.<=      = "\ensuremath{\leq}"+%format M.>=      = "\ensuremath{\geq}"+%format M.>       = "\ensuremath{>}"+%endif+\end{code}++%-------------------------------=  --------------------------------------------+\subsection{New code style}+%-------------------------------=  --------------------------------------------++\begin{code}+%elif style == newcode+%subst comment a        = "-- " a+%subst nested a         = "{- " a " -}"+%subst code a           = a "'n"+%subst newline          = "'n"+%subst dummy            =+%subst pragma a         = "{-# " a " #-}"+%subst numeral a        = a+%subst keyword a        = a+%subst spaces a         = a+%subst special a        = a+%subst space            = " "+%subst conid a          = a+%subst varid a          = a+%subst consym a         = a+%subst varsym a         = a+%subst char a           = "''" a "''"+%subst string a         = "'d" a "'d"+\end{code}++%-------------------------------=  --------------------------------------------+\subsection{Math and Poly style}+%-------------------------------=  --------------------------------------------++Some things modified due to introduction of @poly@ formatter by ks,+17.07.2003. Since both formatters share a lot of declarations, both+declare |anyMath| to be true. The common parts are then declared+in a conditional checking |anyMath|.++\begin{code}+%elif style == math+%subst phantom a	= "\phantom{" a "\mbox{}}"+%subst comment a	= "\mbox{\qquad-{}- " a "}"+%subst nested a	        = "\mbox{\enskip\{- " a " -\}\enskip}"+%if array+%subst code a    	= "\[\begin{array}{@{}lcl}'n\hspace{\lwidth}&\hspace{\cwidth}&\\[-10pt]'n" a "'n\end{array}\]"+%subst column3 l c r	= "{}" l " & " c " & {" r "}"+%subst column1 a	= "\multicolumn{3}{@{}l}{" a "}"+%else+%subst code a    	= "\begin{tabbing}'n\qquad\=\hspace{\lwidth}\=\hspace{\cwidth}\=\+\kill'n" a "'n\end{tabbing}"+%subst column3 l c r	= "$" l "$ \> \makebox[\cwidth]{$" c "$} \> ${" r "}$"+%subst column1 a	= "${" a "}$"+%endif+%subst newline   	= "\\'n"+%subst blankline 	= "\\[1mm]'n"+%let anyMath            = True+%elif style == poly+%subst comment a	= "\mbox{\onelinecomment " a "}"+%subst nested a	        = "\mbox{\commentbegin " a " \commentend}"+%if array+%subst code a    	= "\['n\begin{parray}\SaveRestoreHook'n" a "\ColumnHook'n\end{parray}'n\]\resethooks'n"+%else+%subst code a    	= "\begingroup\par\noindent\advance\leftskip\mathindent\('n\begin{pboxed}\SaveRestoreHook'n" a "\ColumnHook'n\end{pboxed}'n\)\par\noindent\endgroup\resethooks'n"+%endif+%subst column c a       = "\column{" c "}{" a "}'n"+%subst fromto b e t     = "\>[" b "]{}" t "{}\<[" e "]'n"+%subst left             = "@{}l@{}"+%subst centered         = "@{}c@{}"+%subst dummycol         = "@{}l@{}"+%subst newline   	= "\\'n"+%subst blankline        = "\\[\blanklineskip]'n"+%subst indent n         = "\hsindent{" n "}"+%let anyMath            = True+%endif+%if anyMath+%let autoSpacing	= True+%subst dummy		= "\cdot "+%subst inline a  	= "\ensuremath{" a "}"+%subst hskip a	        = "\hskip" a "em\relax"+%subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%if latex209+%subst numeral a 	= "{\mathrm " a "}"+%subst keyword a 	= "{\mathbf " a "}"+%else+%subst numeral a 	= "\mathrm{" a "}"+%subst keyword a 	= "\mathbf{" a "}"+%endif+%subst spaces a		= a+%subst special a	= a+%subst space     	= "\;"+%subst conid a   	= "\Conid{" a "}"+%subst varid a   	= "\Varid{" a "}"+%subst consym a  	= "\mathbin{" a "}"+%subst varsym a  	= "\mathbin{" a "}"+%subst char a    	= "\text{\tt ''" a "''}"+%subst string a  	= "\text{\tt \char34 " a "\char34}"+%format _          = "\anonymous "+%format ->         = "\to "+%format <-         = "\leftarrow "+%format =>         = "\Rightarrow "+%format \          = "\lambda "+%format |          = "\mid "+%format {          = "\{\mskip1.5mu "+%format }          = "\mskip1.5mu\}"+%format [          = "[\mskip1.5mu "+%format ]          = "\mskip1.5mu]"+%format =          = "\mathrel{=}"+%format ..         = "\mathinner{\ldotp\ldotp}"+%format ~          =  "\mathord{\sim}"+%format @          =  "\mathord{@}"+%format .          = "\mathbin{\circ}"+%format !!         = "\mathbin{!!}"+%format ^          = "\mathbin{\uparrow}"+%format ^^         = "\mathbin{\uparrow\uparrow}"+%format **         = "\mathbin{**}"+%format /          = "\mathbin{/}"+%format `quot`     = "\mathbin{\Varid{`quot`}}"+%format `rem`      = "\mathbin{\Varid{`rem`}}"+%format `div`      = "\mathbin{\Varid{`div`}}"+%format `mod`      = "\mathbin{\Varid{`mod`}}"+%format :%         = "\mathbin{:\%}"+%format %          = "\mathbin{\%}"+%format :          = "\mathbin{:}"+%format ++         = "\plus "+%format ==         = "\equiv "+%% ODER: format ==         = "\mathrel{==}"+%format /=         = "\not\equiv "+%% ODER: format /=         = "\neq "+%format <=         = "\leq "+%format >=         = "\geq "+%format `elem`     = "\in "+%format `notElem`  = "\notin "+%format &&         = "\mathrel{\wedge}"+%format ||         = "\mathrel{\vee}"+%format >>         = "\sequ "+%format >>=        = "\bind "+%format $          = "\mathbin{\$}"+%format `seq`      = "\mathbin{\Varid{`seq`}}"+%format !          = "\mathbin{!}"+%format //         = "\mathbin{//}"+%format undefined  = "\bot "+%format not	   = "\neg "+\end{code}+%+Problem: |!| wird sowohl als Infix-Operator als auch prefix f"ur+Striktheitsannotationen verwendet (|"\mathord{!}"|).++Unterst"utzung f"ur Meta-Haskell.+%+\begin{code}+%if meta+%format M.a = "a"+%format M.b = "b"+\end{code}+etc~(for all lower and upper case letters).+%if style == code+\begin{code}+%format M.c = "c"+%format M.d = "d"+%format M.e = "e"+%format M.f = "f"+%format M.g = "g"+%format M.h = "h"+%format M.i = "i"+%format M.j = "j"+%format M.k = "k"+%format M.l = "l"+%format M.m = "m"+%format M.n = "n"+%format M.o = "o"+%format M.p = "p"+%format M.q = "q"+%format M.r = "r"+%format M.s = "s"+%format M.t = "t"+%format M.u = "u"+%format M.v = "v"+%format M.w = "w"+%format M.x = "x"+%format M.y = "y"+%format M.z = "z"+%format M.A = "A"+%format M.B = "B"+%format M.C = "C"+%format M.D = "D"+%format M.E = "E"+%format M.F = "F"+%format M.G = "G"+%format M.H = "H"+%format M.I = "I"+%format M.J = "J"+%format M.K = "K"+%format M.L = "L"+%format M.M = "M"+%format M.N = "N"+%format M.O = "O"+%format M.P = "P"+%format M.Q = "Q"+%format M.R = "R"+%format M.S = "S"+%format M.T = "T"+%format M.U = "U"+%format M.V = "V"+%format M.W = "W"+%format M.X = "X"+%format M.Y = "Y"+%format M.Z = "Z"+\end{code}+%endif+\begin{code}+%format M.alpha   = "\alpha "+%format M.beta    = "\beta "+\end{code}+etc~(for all lower and upper case greek letters).+%if style == code+\begin{code}+%format M.gamma   = "\gamma "+%format M.delta   = "\delta "+%format M.epsilon = "\epsilon "+%format M.zeta    = "\zeta "+%format M.eta     = "\eta "+%format M.theta   = "\theta "+%format M.iota    = "\iota "+%format M.kappa   = "\kappa "+%format M.lambda  = "\lambda "+%format M.mu      = "\mu "+%format M.nu      = "\nu "+%format M.xi      = "\xi "+%format M.pi      = "\pi "+%format M.rho     = "\rho "+%format M.sigma   = "\sigma "+%format M.tau     = "\tau "+%format M.upsilon = "\upsilon "+%format M.phi     = "\phi "+%format M.chi     = "\chi "+%format M.psi     = "\psi "+%format M.omega   = "\omega "+%format M.Gamma   = "\Gamma "+%format M.Delta   = "\Delta "+%format M.Theta   = "\Theta "+%format M.Lambda  = "\Lambda "+%format M.Xi      = "\Xi "+%format M.Pi      = "\Pi "+%format M.Sigma   = "\Sigma "+%format M.Upsilon = "\Upsilon "+%format M.Phi     = "\Phi "+%format M.Psi     = "\Psi "+%format M.Omega   = "\Omega "+\end{code}+%endif+\begin{code}+%format M.forall  = "\forall "+%format M.exists  = "\exists "+%format M.not     = "\neg "+%format ==>       = "\enskip\Longrightarrow\enskip "+%format <==       = "\enskip\Longleftarrow\enskip "+%format /\        = "\enskip\mathrel{\wedge}\enskip "+%format \/        = "\enskip\mathrel{\vee}\enskip "+%format M.=       = "="+%format M./=      = "\neq "+%format M.<       = "<"+%format M.<=      = "\leq "+%format M.>=      = "\geq "+%format M.>       = ">"+%endif+%endif+\end{code}++%-------------------------------=  --------------------------------------------+\section{\LaTeX commands}+%-------------------------------=  --------------------------------------------++New, 21.11.2005: @lhs2TeX.sty@ is now included from @lhs2TeX.fmt@.++\begin{code}+%include lhs2TeX.sty+\end{code}++\begin{code}+%endif+\end{code}
+ lhs2TeX.sty.lit view
@@ -0,0 +1,197 @@+\begin{code}+%if False+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+%endif+%if not lhs2tex_lhs2tex_sty_read+%let lhs2tex_lhs2tex_sty_read = True+%include lhs2TeX.fmt+%+%if style /= newcode+%+\makeatletter+\@@ifundefined{lhs2tex.lhs2tex.sty.read}%+  {\@@namedef{lhs2tex.lhs2tex.sty.read}{}%+   \newcommand\SkipToFmtEnd{}%+   \newcommand\EndFmtInput{}%+   \long\def\SkipToFmtEnd#1\EndFmtInput{}%+  }\SkipToFmtEnd++\newcommand\ReadOnlyOnce[1]{\@@ifundefined{#1}{\@@namedef{#1}{}}\SkipToFmtEnd}+\end{code}++%-------------------------------=  --------------------------------------------+\section{\TeX\ definitions}+%-------------------------------=  --------------------------------------------++\begin{code}+%if latex209+\input{amstext.sty}+\input{amssymb.sty}+\input{stmaryrd.sty}+\newcommand\ensuremath[1]{\ifmmode#1\else\mbox{$#1$}\fi}+%if euler+\input{euler.sty}+%endif+%else+\usepackage{amstext}+\usepackage{amssymb}+\usepackage{stmaryrd}+%if euler+\usepackage{euler}+%endif+%endif+\end{code}+%+\NB Die bedingte Formatierung wird \emph{nicht} verwendet, um+gleichzeitig Math und Verbatim formatieren zu k"onnen.++%-------------------------------=  --------------------------------------------+\subsection{Typewriter style}+%-------------------------------=  --------------------------------------------++ks, 17.07.2003: Added a conditional that only includes this part+if the selected style is typewriter style.++ks, 28.07.2003: Removed the conditional again as it breaks+compatibility. Not sure what to do here. Maybe create a new,+clean @lhs2TeX.sty@ that should be included into new documents.++\begin{code}+%if not latex209+\DeclareFontFamily{OT1}{cmtex}{}+\DeclareFontShape{OT1}{cmtex}{m}{n}+  {<5><6><7><8>cmtex8+   <9>cmtex9+   <10><10.95><12><14.4><17.28><20.74><24.88>cmtex10}{}+\DeclareFontShape{OT1}{cmtex}{m}{it}+  {<-> ssub * cmtt/m/it}{}+\newcommand{\texfamily}{\fontfamily{cmtex}\selectfont}+%if underlineKeywords+\usepackage{ulem}\normalem+%else+\DeclareFontShape{OT1}{cmtt}{bx}{n}+  {<5><6><7><8>cmtt8+   <9>cmbtt9+   <10><10.95><12><14.4><17.28><20.74><24.88>cmbtt10}{}+\DeclareFontShape{OT1}{cmtex}{bx}{n}+  {<-> ssub * cmtt/bx/n}{}+\newcommand{\tex}[1]{\text{\texfamily#1}}	% NEU+%endif+%endif++\newcommand{\Sp}{\hskip.33334em\relax}+\end{code}++%-------------------------------=  --------------------------------------------+\subsection{Math style}+%-------------------------------=  --------------------------------------------++ks, 17.07.2003: As with the typewriter path, this is now conditionally+included for math or poly mode.++\begin{code}+%if (style == math) || (style == poly)+%if times+\usepackage{times}\renewcommand{\ttdefault}{cmtt}+\SetMathAlphabet{\mathrm}{normal}{OT1}{ptm}{m}{n}+\SetMathAlphabet{\mathbf}{normal}{OT1}{ptm}{bx}{n}+\SetMathAlphabet{\mathit}{normal}{OT1}{ptm}{m}{it}+%endif++%if style == math+\newlength{\lwidth}\setlength{\lwidth}{4.5cm}+\newlength{\cwidth}\setlength{\cwidth}{8mm} % 3mm+%endif++%if latex209+\newcommand{\Conid}[1]{{\mathit #1}}+\newcommand{\Varid}[1]{{\mathit #1}}+\newcommand{\anonymous}{\_}+%else+\newcommand{\Conid}[1]{\mathit{#1}}+\newcommand{\Varid}[1]{\mathit{#1}}+\newcommand{\anonymous}{\kern0.06em \vbox{\hrule\@@width.5em}}+%endif+\newcommand{\plus}{\mathbin{+\!\!\!+}}+\newcommand{\bind}{\mathbin{>\!\!\!>\mkern-6.7mu=}}+\newcommand{\sequ}{\mathbin{>\!\!\!>}}+%if not standardsymbols+\renewcommand{\leq}{\leqslant}+\renewcommand{\geq}{\geqslant}+%endif+%endif+\end{code}++The following definitions facilitate the saving and restoring+of column width information as well as the redefinition of+column specifiers. It only works for @poly@ style.++\begin{code}+%if style == poly+\usepackage{polytable}++%mathindent has to be defined+\@@ifundefined{mathindent}%+  {\newdimen\mathindent\mathindent\leftmargini}%+  {}%++\def\resethooks{%+  \global\let\SaveRestoreHook\empty+  \global\let\ColumnHook\empty}+\newcommand*{\savecolumns}[1][default]%+  {\g@@addto@@macro\SaveRestoreHook{\savecolumns[#1]}}+\newcommand*{\restorecolumns}[1][default]%+  {\g@@addto@@macro\SaveRestoreHook{\restorecolumns[#1]}}+\newcommand*{\aligncolumn}[2]%+  {\g@@addto@@macro\ColumnHook{\column{#1}{#2}}}++\resethooks++%if standardsymbols+\newcommand{\onelinecommentchars}{\quad--- }+%else+\newcommand{\onelinecommentchars}{\quad-{}- }+%endif+\newcommand{\commentbeginchars}{\enskip\{-}+\newcommand{\commentendchars}{-\}\enskip}++\newcommand{\visiblecomments}{%+  \let\onelinecomment=\onelinecommentchars+  \let\commentbegin=\commentbeginchars+  \let\commentend=\commentendchars}++\newcommand{\invisiblecomments}{%+  \let\onelinecomment=\empty+  \let\commentbegin=\empty+  \let\commentend=\empty}++\visiblecomments++\newlength{\blanklineskip}+\setlength{\blanklineskip}{1mm}++\newcommand{\hsindent}[1]{\quad}% default is fixed indentation+%endif+\end{code}++%-------------------------------=  --------------------------------------------+\subsection{Some useful definitions}+%-------------------------------=  --------------------------------------------++\begin{code}+\newcommand{\NB}{\textbf{NB}}+\newcommand{\Todo}[1]{$\langle$\textbf{To do:}~#1$\rangle$}++\makeatother+\EndFmtInput+\end{code}++\begin{code}+%+%endif+%endif+\end{code}
+ lhs2tex.cabal view
@@ -0,0 +1,15 @@+cabal-version:  >=1.1.6+name:		lhs2tex+version:	1.12+license:	GPL+license-file:	LICENSE+author:		Ralf Hinze <ralf@informatik.uni-bonn.de>, Andres Loeh <lhs2tex@andres-loeh.de>+maintainer:	Andres Loeh <lhs2tex@andres-loeh.de>+stability:	stable+homepage:	http://www.andres-loeh.de/lhs2tex/+package-url:	http://www.andres-loeh.de/lhs2tex/lhs2tex-1.11.tar.gz+synopsis:	Preprocessor for typesetting Haskell sources with LaTeX+build-depends:	base, regex-compat++executable:	lhs2TeX+main-is:	Main.lhs
+ mkinstalldirs view
@@ -0,0 +1,40 @@+#! /bin/sh+# mkinstalldirs --- make directory hierarchy+# Author: Noah Friedman <friedman@prep.ai.mit.edu>+# Created: 1993-05-16+# Public domain++# $Id: mkinstalldirs,v 1.1 2003/05/07 11:33:44 cvs-4 Exp $++errstatus=0++for file+do+   set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`+   shift++   pathcomp=+   for d+   do+     pathcomp="$pathcomp$d"+     case "$pathcomp" in+       -* ) pathcomp=./$pathcomp ;;+     esac++     if test ! -d "$pathcomp"; then+        echo "mkdir $pathcomp" 1>&2++        mkdir "$pathcomp" || lasterr=$?++        if test ! -d "$pathcomp"; then+  	  errstatus=$lasterr+        fi+     fi++     pathcomp="$pathcomp/"+   done+done++exit $errstatus++# mkinstalldirs ends here
+ polytable/lazylist.sty view
@@ -0,0 +1,112 @@+% Filename: Lambda.sty+% Author: Alan Jeffrey+% Last modified: 12 Feb 1990+% Modified 24 July 2003 by Robin Fairbairns, to change file name and+%                       licence requirements, at Alan Jeffrey's request+%+% This package is (c) 1990 Alan Jeffrey.+%+% Version 1.0a+%+% Use and distribution are subject to the LaTeX Project Public+% License (lppl), version 1.2 (or any later version, at your+% convenience).+%+% A copy of the latest version of lppl may be found at+% http://www.latex-project.org/lppl.txt+%+% See the Gnu manifesto for details on why software ought to be free.+%+% Tugboat are given permission to publish any or all of this.+%+% This package provides a pile of lambda-calculus and list-handling+% macros of an incredibly obtuse nature.  Read lazylist.tex to find+% out what they all do and how they do it.  This \TeX\ code was+% formally verified.+%+% Alan Jeffrey, 25 Jan 1990.++\def\Identity#1{#1}++\def\Error%+   {\errmessage{Abandon verification all +                ye who enter here}}++\def\First#1#2{#1}+\def\Second#1#2{#2}++\def\Compose#1#2#3{#1{#2{#3}}}++\def\Twiddle#1#2#3{#1{#3}{#2}}++\let\True=\First+\let\False=\Second+\let\Not=\Twiddle++\def\And#1#2{#1{#2}\False}+\def\Or#1#2{#1\True{#2}}++\def\Lift#1#2#3#4{#1{#4}{#2}{#3}{#4}}++\def\Lessthan#1#2{\TeXif{\ifnum#1<#2 }}++\def\gobblefalse\else\gobbletrue\fi#1#2%+   {\fi#1}+\def\gobbletrue\fi#1#2%+   {\fi#2}+\def\TeXif#1%+   {#1\gobblefalse\else\gobbletrue\fi}++\def\Nil#1#2{#2}+\def\Cons#1#2#3#4{#3{#1}{#2}}+\def\Stream#1{\Cons{#1}{\Stream{#1}}}+\def\Singleton#1{\Cons{#1}\Nil}++\def\Head#1{#1\First\Error}+\def\Tail#1{#1\Second\Error}++\def\Foldl#1#2#3%+   {#3{\Foldl@{#1}{#2}}{#2}}+\def\Foldl@#1#2#3#4%+   {\Foldl{#1}{#1{#2}{#3}}{#4}}+\def\Foldr#1#2#3%+   {#3{\Foldr@{#1}{#2}}{#2}}+\def\Foldr@#1#2#3#4%+   {#1{#3}{\Foldr{#1}{#2}{#4}}}++\def\Cat#1#2{\Foldr\Cons{#2}{#1}}++\def\Reverse{\Foldl{\Twiddle\Cons}\Nil}++\def\All#1{\Foldr{\Compose\And{#1}}\True}+\def\Some#1{\Foldr{\Compose\Or{#1}}\False}+\def\Isempty{\All{\First\False}}++\def\Filter#1%+   {\Foldr{\Lift{#1}\Cons\Second}\Nil}++\def\Map#1{\Foldr{\Compose\Cons{#1}}\Nil}++\def\Insert#1#2#3%+   {#3{\Insert@{#1}{#2}}{\Singleton{#2}}}+\def\Insert@#1#2#3#4%+   {#1{#2}{#3}%+      {\Cons{#2}{\Cons{#3}{#4}}}%+      {\Cons{#3}{\Insert{#1}{#2}{#4}}}}+\def\Insertsort#1{\Foldr{\Insert{#1}}\Nil}++\def\Unlistize#1{[#1\Unlistize@{}]}+\def\Unlistize@#1{#1\Foldr\Commaize{}}+\def\Commaize#1#2{, #1#2}++\def\Listize[#1]%+   {\Listize@#1,\relax]}+\def\Listize@#1,#2]%+   {\TeXif{\ifx\relax#2}%+        {\Singleton{#1}}%+        {\Cons{#1}{\Listize@#2]}}}++\def\Show#1[#2]%+   {\Unlistize{#1{\Listize[#2]}}}++
+ polytable/polytable.pdf view

binary file changed (absent → 204282 bytes)

+ polytable/polytable.sty view
@@ -0,0 +1,784 @@+%%+%% This is file `polytable.sty',+%% generated with the docstrip utility.+%%+%% The original source files were:+%%+%% polytable.dtx  (with options: `package')+%% ++\NeedsTeXFormat{LaTeX2e}+\ProvidesPackage{polytable}%+   [2005/04/25 v0.8.2 `polytable' package (Andres Loeh)]+\let\PT@original@And\And+\RequirePackage{lazylist}+\let\PT@And\And+\def\PT@prelazylist+  {\let\And\PT@And}+\def\PT@postlazylist+  {\let\And\PT@original@And}+\PT@postlazylist+\RequirePackage{array}+\DeclareOption{debug} {\AtEndOfPackage\PT@debug}+\DeclareOption{info}  {\AtEndOfPackage\PT@info}+\DeclareOption{silent}{\AtEndOfPackage\PT@silent}+\newdimen\PT@colwidth+\newcount\PT@cols+\newcount\PT@table+\newtoks\PT@toks+\newif\ifPT@changed+\newread\PT@in+\newwrite\PT@out+\def\PT@allcols{\Nil}+\let\PT@infromto\empty+\let\PT@currentwidths\empty+\def\PT@false{0}+\def\PT@true{1}+\let\PT@inrestore\PT@false+\newcommand{\defaultcolumn}[1]{\gdef\PT@defaultcolumnspec{#1}}+\newcommand{\nodefaultcolumn}{\global\let\PT@defaultcolumnspec\undefined}+\DeclareOption{defaultcolumns}{\defaultcolumn{l}}+\newcommand{\memorytables}{%+  \let\PT@preparewrite\@gobble+  \let\PT@add         \PT@addmem+  \let\PT@prepareread \PT@preparereadmem+  \let\PT@split       \PT@splitmem+  \let\PT@finalize    \relax+}+\newcommand{\disktables}{%+  \let\PT@preparewrite\PT@preparewritefile+  \let\PT@add         \PT@addfile+  \let\PT@prepareread \PT@preparereadfile+  \let\PT@split       \PT@splitfile+  \let\PT@finalize    \PT@finalizefile+}+\DeclareOption{memory}{\AtEndOfPackage\memorytables}+\ProcessOptions+\newcommand*{\PT@debug}+  {\def\PT@debug@ ##1{\typeout{(polytable) ##1}}+   \PT@info}+\newcommand*{\PT@info}+  {\def\PT@typeout@ ##1{\typeout{(polytable) ##1}}}+\let\PT@debug@\@gobble+\let\PT@typeout@\@gobble+\def\PT@warning{\PackageWarning{polytable}}%+\def\PT@silent+  {\let\PT@typeout@\@gobble\let\PT@warning\@gobble}+\def\PT@aligndim#1#2#3\@@{%+  \ifnum#1=0+    \if #2p%+      \PT@aligndim@0.0pt\space\space\space\space\space\@@+    \else+      \PT@aligndim@#1#2#3\space\space\space\space\space\space\space\space\@@+    \fi+  \else+    \PT@aligndim@#1#2#3\space\space\space\space\space\space\space\space\@@+  \fi}++\def\PT@aligndim@#1.#2#3#4#5#6#7#8#9\@@{%+  \ifnum#1<10 \space\fi+  \ifnum#1<100 \space\fi+  \ifnum#1<\@m\space\fi+  \ifnum#1<\@M\space\fi+  #1.#2#3#4#5#6#7#8\space\space}++\def\PT@aligncol#1{%+  \PT@aligncol@#1\space\space\space\space\space\space\space\space\@@}++\def\PT@aligncol@#1#2#3#4#5#6#7#8#9\@@{%+  #1#2#3#4#5#6#7#8\space\space}+\def\PT@rerun+  {\PT@typeout@{We have to rerun LaTeX ...}%+   \AtEndDocument+     {\PackageWarning{polytable}%+        {Column widths have changed. Rerun LaTeX.\@gobbletwo}}%+   \global\let\PT@rerun\relax}+\def\PT@listopmacro #1#2#3% #1 #3 to the list #2+  {\def\PT@temp{#1{#3}}%+   \expandafter\expandafter\expandafter+     \def\expandafter\expandafter\expandafter+     #2\expandafter\expandafter\expandafter+     {\expandafter\PT@temp\expandafter{#2}}}++\def\PT@consmacro{\PT@listopmacro\Cons}+\def\PT@appendmacro{\PT@listopmacro\Cat}+\def\PT@gaddendmacro #1#2% add #2 to the end of #1+  {\PT@expanded{\gdef #1}{#1#2}}+\def\PT@expanded #1#2%+  {\expandafter\Twiddle\expandafter\Identity\expandafter{#2}{#1}}+\def\PT@enamedef #1% sets name #1 to the expansion of #2+  {\PT@expanded{\@namedef{#1}}}+\def\PT@addoptargtomacro+  {\PT@add@argtomacro\PT@makeoptarg}+\def\PT@addargtomacro+  {\PT@add@argtomacro\PT@makearg}++\def\PT@add@argtomacro#1#2#3%+  {\PT@expanded{\PT@expanded{\gdef\PT@temp}}{\csname #3\endcsname}%+   #1%+   \PT@expanded{\PT@gaddendmacro{#2}}{\PT@temp}}++\def\PT@makeoptarg%+  {\PT@expanded{\def\PT@temp}{\expandafter[\PT@temp]}}+\def\PT@makearg%+  {\PT@expanded{\def\PT@temp}{\expandafter{\PT@temp}}}+\newcommand*{\PT@gobbleoptional}[1][]{\ignorespaces}+\def\PT@addmem#1#2{\PT@gaddendmacro #2{\PT@elt{#1}}}+\def\PT@splitmem#1#2{#1\PT@nil{#2}{#1}}++\def\PT@elt#1#2\PT@nil#3#4{\gdef #3{#1}\gdef #4{#2}}++\def\PT@queuefilename{\jobname.ptb}++\def\PT@addfile#1#2{%+  \immediate\write #2{\string\def\string\PTtemp{#1}\string\empty}}++\def\PT@splitfile#1#2{%+  \ifeof #1%+    \let #2=\empty+  \else+    \read #1 to#2%+    %\show #2%+    #2% hack, because it essentially ignores #2+    \PT@expanded{\def #2}{\PTtemp}%+    %\show #2%+  \fi}+++\def\PT@preparereadmem#1#2{%+  \global\let #1=#2}++\def\PT@preparewritefile#1{%+  \immediate\openout\PT@out\PT@queuefilename\relax+  \let #1\PT@out}++\def\PT@preparereadfile#1#2{%+  \immediate\closeout\PT@out+  \openin\PT@in\PT@queuefilename\relax+  \let #1\PT@in}++\def\PT@finalizefile{%+  \closein\PT@in}++\disktables+\newcommand*{\beginpolytable}%+  {\edef\PT@environment{\@currenvir}%+   \begingroup+   % new in v0.7: save counters+   \PT@savecounters+   \PT@toks{}% initialise token register+   \PT@scantoend}+\let\endpolytable=\relax+\newcommand{\PT@scantoend}% LaTeX check+\long\def\PT@scantoend #1\end #2%+  {\PT@toks\expandafter{\the\PT@toks #1}%+   \def\PT@temp{#2}%+   \ifx\PT@temp\PT@environment+     \global\let\PT@columnqueue     \empty+     \global\let\PT@columnreference \undefined+     \PT@preparewrite\PT@columnqueue+     \expandafter\PT@getwidths+   \else+     \PT@toks\expandafter{\the\PT@toks\end{#2}}%+     \expandafter\PT@scantoend+   \fi}+\def\PT@getwidths+  {\let\column         \PT@firstrun@column+   \let\savecolumns    \PT@savewidths+   \let\restorecolumns \PT@restorewidths+   \column{@begin@}{@{}l@{}}%+   \column{@end@}{}%+   \PT@cols=0\relax%+   \let\fromto          \PT@fromto+   \let\PT@processentry \PT@checkwidth+   \let\PT@scanbegin    \PT@scanbeginfree+   \let\\=              \PT@resetcolumn+   \let\nextline        \PT@resetcolumn+   \let\>=              \PT@fromopt+   \let\==              \PT@from+   \let\<=              \PT@toopt+   \global\PT@changedfalse % nothing has changed so far+   \PT@resetcolumn % we are at the beginning of a line+   \the\PT@toks+   \@ifundefined{PT@scanning}%+     {}{\PT@resetcolumn\relax}%+   \ifx\column\PT@otherrun@column+   \else+      % we are in first run, print extra info+      \PT@prelazylist+      \PT@typeout@{\PT@environment: \the\PT@cols\space columns, %+                                    \PT@Print\PT@allcols}%+      \PT@postlazylist+   \fi+   \let\PT@firstrun@column \PT@otherrun@column+   \let\savecolumns        \PT@gobbleoptional+   \let\restorecolumns     \PT@gobbleoptional+   \let\PT@savewidths      \PT@gobbleoptional+   \let\PT@restorewidths   \PT@gobbleoptional+   \PT@restorecounters+   \ifPT@changed+      % we need to rerun if something has changed+      \PT@typeout@{There were changes; another trial run needed.}%+      \expandafter\PT@getwidths+   \else+      % we are done and can do the sorting+      \PT@typeout@{There were no changes; reached fixpoint.}%+      \expandafter\PT@sortcols+   \fi}+\def\PT@savecounters+  {\begingroup+      \def\@elt ##1%+        {\global\csname c@##1\endcsname\the\csname c@##1\endcsname}%+      \xdef\PT@restorecounters{\cl@@ckpt}%+   \endgroup}+\def\PT@sortcols+  {\PT@prelazylist+   \edef\PT@sortedlist+     {\Foldr{\noexpand\Cons}{\noexpand\Nil}%+        {\Insertsort\PT@ltmax\PT@allcols}}%+   \PT@typeout@{Sorted columns:}%+   \PT@PrintWidth\PT@sortedlist+   \PT@postlazylist+   \PT@cols=0\relax%+   \PT@prelazylist+   \PT@Execute{\Map\PT@numbercol\PT@sortedlist}%+   \PT@postlazylist+   \edef\PT@lastcol@{\PT@StripColumn\PT@lastcol}%+   \PT@typeout@{Numbered successfully, %+                last column is \PT@lastcol@}%+      \ifx\PT@currentwidths\empty+      \else+         \PT@typeout@{Saving table information for \PT@currentwidths .}%+         \PT@expanded\PT@saveinformation\PT@currentwidths+      \fi+   \PT@typeset}+\def\PT@typeset+  {\PT@typeout@{Typesetting the table ...}%+   \let\PT@processentry           \PT@placeinbox+   \let\PT@scanbegin              \PT@scanbeginwidth+   \let\\=                        \PT@resetandcr+   \let\nextline                  \PT@resetandcr+   \PT@prepareread\PT@columnreference\PT@columnqueue+   \let\@arraycr                  \PT@resetandcr+   \PT@resetcolumn % we are at the beginning of a line+   \PT@begin%+   \the\PT@toks+   \PT@fill% new in 0.7.3: balance the last line+   \PT@finalize% finalize the queue (possibly close file)+   \PT@end+   \endgroup+   \PT@typeout@{Finished.}%+   \expandafter\end\expandafter{\PT@environment}}%+\newcommand{\PT@from}[1]%+  {\PT@checkendentry{#1}\PT@dofrom{#1}}++\newcommand{\PT@fromopt}[1][]%+  {\def\PT@temp{#1}%+   \ifx\PT@temp\empty+     % set default column name+     \def\PT@temp{\PT@currentcolumn .}%+   \fi+   \PT@expanded\PT@from\PT@temp}++\newcommand{\PT@toopt}[1][]%+  {\def\PT@temp{#1}%+   \ifx\PT@temp\empty+     % set default column name+     \def\PT@temp{\PT@currentcolumn .}%+   \fi+   \PT@expanded\PT@checkendentry\PT@temp+   \let\PT@scanning\undefined}+\newcommand*{\PT@dofrom}[1]%+  {\edef\PT@currentcolumn{#1}%+   \let\PT@scanning\PT@currentcolumn+   \let\PT@currentpreamble\relax% necessary for preparescan+   \@ifnextchar[%]+     {\PT@expanded\PT@dospecfrom\PT@currentcolumn}%+     {\PT@expanded\PT@dodofrom  \PT@currentcolumn}}++\newcommand*{\PT@dospecfrom}{}% LaTeX check+\def\PT@dospecfrom #1[#2]%+  {\PT@checkglobalfrom #2\PT@nil{#1}%+   \PT@dodofrom{#1}}++\newcommand*{\PT@checkglobalfrom}{}% LaTeX check+\def\PT@checkglobalfrom+  {\@ifnextchar!\PT@getglobalfrom\PT@ignorefrom}++\newcommand*{\PT@getglobalfrom}{}% LaTeX check+\def\PT@getglobalfrom!#1\PT@nil#2%+  {\column{#2}{#1}}++\newcommand*{\PT@ignorefrom}{}% LaTeX check+\def\PT@ignorefrom #1\PT@nil#2%+  {\def\PT@currentpreamble{#1}}++\newcommand*{\PT@dodofrom}[1]%+  {\@ifundefined{PT@columnreference}%+     {% trial run+      \ifx\column\PT@otherruncolumn+      \else+        % first run+        \let\PT@storeendcolumn\PT@add+      \fi+      \def\PT@temp{@end@}}%+     {% final run+      \PT@split\PT@columnreference\PT@temp+      %\PT@typeout@{splitted: \PT@temp}+     }%+   \PT@expanded{\PT@expanded\PT@preparescan\PT@currentcolumn}\PT@temp+   \PT@scanbegin}++\let\PT@storeendcolumn\@gobbletwo+\newcommand*{\PT@fromto}[3]%+  {\PT@checkendentry{#1}%+   \let\PT@scanning\undefined+   \PT@infromto+   \def\PT@infromto{%+     \PackageError{polytable}{Nested fromto}{}}%+   \let\PT@currentpreamble\relax% necessary for preparescan+   \PT@preparescan{#1}{#2}%+   \PT@scanbegin #3\PT@scanend% defines \@curfield+   \PT@processentry{#1}{#2}%+   \let\PT@infromto\empty+   \ignorespaces}+\newcommand*{\PT@checkendentry}% takes one argument+  {\@ifundefined{PT@scanning}%+     {\let\PT@temp\@gobble}%+     {\let\PT@temp\PT@endentry}%+   \PT@temp}+++\newcommand*{\PT@endentry}[1]%+  {\PT@scanend+   \edef\PT@temp{#1}%+   \PT@expanded\PT@storeendcolumn\PT@temp\PT@columnqueue+   \let\PT@storeendcolumn\@gobbletwo+   \PT@expanded{\PT@expanded\PT@processentry\PT@currentcolumn}\PT@temp}+\newcommand\PT@firstrun@column[3][0pt]%+  {\@ifundefined{PT@col@#2.type}%+      {\PT@typeout@{Defining column \PT@aligncol{#2} at #1.}%+       \@namedef{PT@col@#2.type}{#3}%+       \@namedef{PT@col@#2.width}{#1}% initialize the width of the column+       % add the new column to the (sortable) list of all columns+       \PT@consmacro\PT@allcols{PT@col@#2}%+       \advance\PT@cols by 1\relax}%+      {\expandafter\ifx\csname PT@col@#2.type\endcsname\empty+         \relax % will be defined in a later table of the same set+       \else+         \begingroup+         \def\PT@temp{PT@col@#2}%+         \ifx\PT@temp\PT@endcol+           \relax % end column is always redefined+         \else+           \PT@warning{Redefining column #2}%+         \fi+         \endgroup+       \fi+       \@namedef{PT@col@#2.type}{#3}%+       \expandafter\ifdim#1>0pt\relax+         \PT@typeout@{Redefining column #2 at #1.}%+         \@namedef{PT@col@#2.width}{#1}%+       \fi+      }%+   \@ifundefined{PT@col@#2.max}%+      {\@namedef{PT@col@#2.max}{#1}%+       \expandafter\let\csname PT@col@#2.trusted\endcsname\PT@true}{}%+   \ignorespaces}+\newcommand\PT@otherrun@column[3][]%+  {\ignorespaces}+\def\PT@checkcoldefined #1%+  {\@ifundefined{PT@col@#1.type}%+      {\@ifundefined{PT@defaultcolumnspec}%+          {\PackageError{polytable}{Undefined column #1}{}}+          {\PT@debug@{Implicitly defining column #1}%+           \PT@expanded{\column{#1}}{\PT@defaultcolumnspec}}}{}%+   \expandafter\ifx\csname PT@col@#1.type\endcsname\empty\relax+      \@ifundefined{PT@defaultcolumnspec}{}%+      {\PT@debug@{Implicitly defining column #1}%+       \PT@expanded{\column{#1}}{\PT@defaultcolumnspec}}%+   \fi}+\def\PT@checkwidth #1#2%+  {\PT@checkcoldefined{#2}% first column should have been checked before+   \def\PT@temp{PT@col@#1}%+   \ifx\PT@currentcol\PT@temp+     \PT@debug@{No need to skip columns.}%+   \else+     \PT@colwidth=\expandafter\@nameuse\expandafter+                    {\PT@currentcol.width}\relax+     \ifdim\PT@colwidth>\csname PT@col@#1.width\endcsname\relax+       % we need to change the width+       \PT@debug@{s \PT@aligncol{#1}: %+                  old=\expandafter\expandafter\expandafter+                        \PT@aligndim\csname PT@col@#1.width\endcsname\@@%+                  new=\expandafter\PT@aligndim\the\PT@colwidth\@@}%+       \PT@changedtrue+       \PT@enamedef{PT@col@#1.width}{\the\PT@colwidth}%+     \fi+     \PT@colwidth=\expandafter\@nameuse\expandafter+                    {\PT@currentcol.max}\relax+     \ifdim\PT@colwidth>\csname PT@col@#1.max\endcsname\relax+       % we need to change the width+       \PT@debug@{S \PT@aligncol{#1}: %+                  old=\expandafter\expandafter\expandafter+                        \PT@aligndim\csname PT@col@#1.max\endcsname\@@%+                  new=\expandafter\PT@aligndim\the\PT@colwidth\@@}%+       \PT@changedtrue+       \PT@checkrerun+       \PT@enamedef{PT@col@#1.max}{\the\PT@colwidth}%+     \fi+     \ifnum\csname PT@col@#1.trusted\endcsname=\PT@false\relax+       \ifdim\PT@colwidth=\csname PT@col@#1.max\endcsname\relax+         \PT@debug@{#1=\the\PT@colwidth\space is now trusted}%+         \expandafter\let\csname PT@col@#1.trusted\endcsname\PT@true%+       \fi+     \fi+   \fi+   \PT@expanded{\def\PT@temp}{\the\wd\@curfield}%+   \global\PT@colwidth=\@nameuse{PT@col@#1.width}%+   \global\advance\PT@colwidth by \PT@temp\relax%+   \ifdim\PT@colwidth>\csname PT@col@#2.width\endcsname\relax+     % we need to change the width+     \PT@debug@{#2 (width \PT@temp) starts after #1 (at \csname PT@col@#1.width\endcsname)}%+     \PT@debug@{c \PT@aligncol{#2}: %+                old=\expandafter\expandafter\expandafter+                      \PT@aligndim\csname PT@col@#2.width\endcsname\@@%+                new=\expandafter\PT@aligndim\the\PT@colwidth\@@}%+     \PT@changedtrue+     \PT@enamedef{PT@col@#2.width}{\the\PT@colwidth}%+   \fi+   \global\PT@colwidth=\@nameuse{PT@col@#1.max}%+   \global\advance\PT@colwidth by \PT@temp\relax%+   \ifdim\PT@colwidth>\csname PT@col@#2.max\endcsname\relax+     % we need to change the width+     \PT@debug@{C \PT@aligncol{#2}: %+                old=\expandafter\expandafter\expandafter+                      \PT@aligndim\csname PT@col@#2.max\endcsname\@@%+                new=\expandafter\PT@aligndim\the\PT@colwidth\@@}%+     \PT@changedtrue+     \PT@checkrerun+     \PT@enamedef{PT@col@#2.max}{\the\PT@colwidth}%+   \fi+   \ifnum\csname PT@col@#2.trusted\endcsname=\PT@false\relax+     \ifdim\PT@colwidth=\csname PT@col@#2.max\endcsname\relax+       \PT@debug@{#2=\the\PT@colwidth\space is now trusted}%+       \expandafter\let\csname PT@col@#2.trusted\endcsname\PT@true%+     \fi+   \fi+   \def\PT@currentcol{PT@col@#2}}+\def\PT@checkrerun+  {\ifnum\PT@inrestore=\PT@true\relax+     \PT@rerun+   \fi}+\newcommand*{\PT@resetcolumn}[1][]%+  {\PT@checkendentry{@end@}%+   \let\PT@currentcolumn\empty%+   \let\PT@scanning\undefined+   \let\PT@currentcol\PT@nullcol+   % TODO: remove these lines if they don't work+   %\let\PT@pre@preamble\empty+   %\PT@scanbeginfree+  }+\def\PT@nullcol{PT@col@@begin@}+\def\PT@endcol{PT@col@@end@}+\def\PT@Execute{\Foldr\PT@Sequence\empty}+\def\PT@Sequence #1#2{#1#2}+\def\PT@ShowColumn #1#2%+  {\PT@ShowColumn@{#1}#2\PT@ShowColumn@}+\def\PT@ShowColumn@ #1PT@col@#2\PT@ShowColumn@+  {#1{#2} }+\def\PT@ShowColumnWidth #1%+  {\PT@typeout@{%+     \PT@ShowColumn\PT@aligncol{#1}:+     \expandafter\expandafter\expandafter+       \PT@aligndim\csname #1.max\endcsname\@@}}+\def\PT@StripColumn #1%+  {\expandafter\PT@StripColumn@#1\PT@StripColumn@}+\def\PT@StripColumn@ PT@col@#1\PT@StripColumn@+  {#1}+\def\PT@Print#1{\PT@Execute{\Map{\PT@ShowColumn\Identity}#1}}+\def\PT@PrintWidth#1{\PT@Execute{\Map\PT@ShowColumnWidth#1}}+\def\PT@TeXif #1%+  {\expandafter\@gobble#1\relax+     \PT@gobblefalse+   \else\relax+     \gobbletrue+   \fi}+\def\PT@gobblefalse\else\relax\gobbletrue\fi #1#2%+  {\fi #1}+\def\PT@ltmax #1#2%+  {\PT@TeXif{\ifdim\csname #1.max\endcsname<\csname #2.max\endcsname}}+\def\PT@numbercol #1%+  {%\PT@typeout@{numbering #1 as \the\PT@cols}%+   \PT@enamedef{#1.num}{\the\PT@cols}%+   \def\PT@lastcol{#1}%+   \advance\PT@cols by 1\relax}+\newcommand{\PT@resetandcr}%+  {\PT@expanded\PT@checkendentry\PT@lastcol@%+   \ifx\PT@currentcol\PT@lastcol+   \else+     \ifx\PT@currentcol\PT@nullcol+       \edef\PT@currentcol{\Head{\Tail\PT@sortedlist}}%+     \fi+     \edef\PT@currentcol@{\PT@StripColumn\PT@currentcol}%+     \PT@typeout@{adding implicit fromto at eol from \PT@currentcol@+                                         \space to \PT@lastcol@}%+     \PT@expanded{\PT@expanded\fromto\PT@currentcol@}\PT@lastcol@+   \fi+   \PT@typeout@{Next line ...}%+   \let\PT@scanning\undefined% needed for resetcolumn+   \PT@resetcolumn\PT@cr}+\newcommand{\PT@fill}%+  {\PT@expanded\PT@checkendentry\PT@lastcol@%+   \ifx\PT@currentcol\PT@lastcol+   \else+     \ifx\PT@currentcol\PT@nullcol+     \else+       \edef\PT@currentcol@{\PT@StripColumn\PT@currentcol}%+       \PT@typeout@{adding implicit fromto from \PT@currentcol@+                                    \space to \PT@lastcol@}%+     \PT@expanded{\PT@expanded\fromto\PT@currentcol@}\PT@lastcol@+   \fi\fi}+\def\PT@placeinbox#1#2%+  {\PT@colwidth=\@nameuse{PT@col@#1.max}%+   \advance\PT@colwidth by -\expandafter\csname\PT@currentcol.max\endcsname+   \leavevmode+   \edef\PT@temp{\PT@StripColumn\PT@currentcol}%+   \PT@typeout@{adding space of width %+                \expandafter\PT@aligndim\the\PT@colwidth\@@+                (\expandafter\PT@aligncol\expandafter{\PT@temp} %+                -> \PT@aligncol{#1})}%+   \hb@xt@\PT@colwidth{%+     {\@mkpream{@{}l@{}}\@addtopreamble\@empty}%+     \let\CT@row@color\relax% colortbl compatibility+     \let\@sharp\empty%+     %\show\@preamble+     \@preamble}%+   \PT@typeout@{adding box \space\space of width %+                \expandafter\PT@aligndim\the\wd\@curfield\@@+                (\PT@aligncol{#1} -> \PT@aligncol{#2})}%+   \box\@curfield+   \def\PT@currentcol{PT@col@#2}%+   \ignorespaces}%+\def\PT@preparescan#1#2%+  {\PT@checkcoldefined{#1}%+   \PT@checkcoldefined{#2}%+   \PT@colwidth=\@nameuse{PT@col@#2.max}%+   \advance\PT@colwidth by -\@nameuse{PT@col@#1.max}\relax%+   \ifmmode+     \PT@debug@{*math mode*}%+     \let\d@llarbegin=$%$+     \let\d@llarend=$%$+     \let\col@sep=\arraycolsep+   \else+     \PT@debug@{*text mode*}%+     \let\d@llarbegin=\begingroup+     \let\d@llarend=\endgroup+     \let\col@sep=\tabcolsep+   \fi+   \ifx\PT@currentpreamble\relax+     \PT@expanded{\PT@expanded{\def\PT@currentpreamble}}%+                 {\csname PT@col@#1.type\endcsname}%+   \fi+   {\PT@expanded\@mkpream\PT@currentpreamble%+    \@addtopreamble\@empty}%+   \let\CT@row@color\relax% colortbl compatibility+   \expandafter\PT@splitpreamble\@preamble\@sharp\PT@nil}+\def\PT@splitpreamble #1\@sharp #2\PT@nil{%+  \let\@sharp=\relax% needed for the following assignment+  \def\PT@terp{#2}%+  \ifx\PT@terp\empty%+    \PackageError{polytable}{Illegal preamble (no columns)}{}%+  \fi+  \PT@splitsplitpreamble{#1}#2\PT@nil}++\def\PT@splitsplitpreamble #1#2\@sharp #3\PT@nil{%+  \def\PT@temp{#3}%+  \ifx\PT@temp\empty%+  \else+    \PackageError{polytable}{Illegal preamble (multiple columns)}{}%+  \fi+  \def\PT@pre@preamble{#1}%+  \def\PT@post@preamble{#2}}%+\def\PT@scanbeginwidth+   {\PT@scanbegin@{\hbox to \PT@colwidth}}++\def\PT@scanbeginfree+   {\PT@scanbegin@{\hbox}}++\def\PT@scanbegin@#1%+   {\setbox\@curfield #1%+    \bgroup+    \PT@pre@preamble\strut\ignorespaces}++\def\PT@scanend+   {\PT@post@preamble+    \egroup}+\newcommand*{\PT@setmaxwidth}[3][\PT@false]% #2 column name, #3 maximum width+  {\@namedef{PT@col@#2.max}{#3}%+   \ifdim#3=0pt\relax+     \expandafter\let\csname PT@col@#2.trusted\endcsname=\PT@true%+   \else+     \expandafter\let\csname PT@col@#2.trusted\endcsname=#1%+   \fi+   \column{#2}{}}%+\def\PT@loadtable#1% #1 table id number+  {%\expandafter\show\csname PT@restore@\romannumeral #1\endcsname+   %\show\column+   \PT@typeout@+     {Calling \expandafter\string+                \csname PT@restore@\romannumeral #1\endcsname.}%+   \let\maxcolumn\PT@setmaxwidth+   %\expandafter\show\csname PT@load@\romannumeral #1\endcsname+   \csname PT@restore@\romannumeral #1\endcsname}+\def\PT@loadtablebyname#1% #1 set name+  {\PT@typeout@{Loading table information for column width set #1.}%+   \PT@loadtable{\csname PT@widths@#1\endcsname}}%+\def\PT@saveinformation#1% #1 set name+  {\PT@expanded{\def\PT@temp}{\csname PT@widths@#1\endcsname}%+   \PT@expanded{\def\PT@temp}%+               {\csname PT@restore@\romannumeral\PT@temp\endcsname}%+   \expandafter\gdef\PT@temp{}% start empty+   % this is: \PT@Execute{\Map{\PT@savecolumn{\PT@temp}}\PT@sortedlist}+   \expandafter\PT@Execute\expandafter{\expandafter+     \Map\expandafter{\expandafter\PT@savecolumn+       \expandafter{\PT@temp}}\PT@sortedlist}}+\def\PT@savecolumn#1#2% #1 macro name, #2 column name+  {\PT@typeout@{saving column #2 in \string #1 ...}%+   \def\PT@temp{#2}%+   \ifx\PT@temp\PT@nullcol+     \PT@typeout@{skipping nullcol ...}%+   \else+     \PT@typeout@{max=\csname #2.max\endcsname, %+                  width=\csname #2.width\endcsname, %+                  trusted=\csname #2.trusted\endcsname}%+     % we need the column command in here+     % we could do the same in \column, but then the location of+     % \save / \restore matters ...+     \PT@gaddendmacro{#1}{\maxcolumn}%+     \ifnum\csname #2.trusted\endcsname=\PT@true\relax+       \PT@gaddendmacro{#1}{[\PT@true]}%+     \fi+     \edef\PT@temp{\PT@StripColumn{#2}}%+     \PT@addargtomacro{#1}{PT@temp}%+     \PT@addargtomacro{#1}{#2.max}%+     \PT@gaddendmacro{#1}{\column}%+     \PT@addoptargtomacro{#1}{#2.width}%+     \edef\PT@temp{\PT@StripColumn{#2}}%+     \PT@addargtomacro{#1}{PT@temp}%+     \PT@addargtomacro{#1}{#2.type}%+     %\show#1%+   \fi+  }+\newcommand*{\PT@savewidths}[1][default@]+  {\PT@typeout@{Executing \string\savecolumns [#1].}%+   \def\PT@currentwidths{#1}%+   \PT@verifywidths{#1}%+   \global\advance\PT@table by 1\relax+   \expandafter\xdef\csname PT@widths@#1\endcsname+     {\the\PT@table}%+   \PT@loadtable{\PT@table}%+   \ignorespaces}+\newcommand*{\PT@restorewidths}[1][default@]+  {\PT@typeout@{Executing \string\restorecolumns [#1].}%+   \def\PT@currentwidths{#1}%+   \let\PT@inrestore\PT@true+   \PT@loadtablebyname{#1}%+   \ignorespaces}+\def\PT@comparewidths#1% #1 full column name+  {\@ifundefined{#1.max}%+     {\PT@typeout@{computed width for #1 is fine ...}}%+     {\ifdim\csname #1.max\endcsname>\csname #1.width\endcsname\relax+        \PT@typeout@{Preferring saved width for \PT@StripColumn{#1}.}%+        \PT@changedtrue+        \PT@colwidth=\@nameuse{#1.max}\relax+        \PT@enamedef{#1.width}{\the\PT@colwidth}%+      \fi}}+\def\PT@trustedmax#1%+  {\PT@TeXif{\ifnum\csname #1.trusted\endcsname=\PT@true}}+\def\PT@equalwidths#1% #1 full column name+  {\@ifundefined{#1.max}{}%+     {\ifdim\csname #1.max\endcsname=\csname #1.width\endcsname\relax+        \PT@typeout@{col #1 is okay ...}%+      \else+        \PT@rerun% a rerun is needed+      \fi}}+\def\PT@verifywidths#1% #1 column width set name+  {\@ifundefined{PT@widths@#1}%+     {\PT@typeout@{Nothing to verify yet for set #1.}%+      \PT@typeout@{Scheduling set #1 for verification at end of document.}%+      \AtEndDocument{\PT@verifywidths{#1}}}%+     {\PT@typeout@{Verifying column width set #1.}%+      \PT@expanded\PT@verify@widths{\csname PT@widths@#1\endcsname}{#1}}}++\def\PT@verify@widths#1#2% #1 set id number, #2 set name+  {\@ifundefined{PT@restore@\romannumeral #1}{}%+     {\begingroup+        \let\column\PT@firstrun@column+        \PT@cols=0\relax%+        \def\PT@allcols{\Nil}%+        \PT@loadtablebyname{#2}%+        \PT@table=#1\relax+        % nullcolumn is not loaded, therefore:+        \@namedef{\PT@nullcol .width}{0pt}%+        % checking trust+        \PT@prelazylist+        \All{\PT@trustedmax}{\PT@allcols}%+           {\PT@typeout@{All maximum widths can be trusted -- writing .max!}%+            \PT@save@table{.max}}%+           {\PT@typeout@{Untrustworthy maximums widths -- writing .width!}%+            \PT@rerun+            \PT@save@table{.width}}%+        \PT@postlazylist+      \endgroup}%+   \PT@typeout@{Verification for #2 successful.}}+\def\PT@save@table#1%+  {\PT@typeout@{Saving column width information.}%+   \if@filesw+     \PT@prelazylist+     {\immediate\write\@auxout{%+        \gdef\expandafter\noexpand+          \csname PT@restore@\romannumeral\PT@table\endcsname+            {\PT@Execute{\Map{\PT@write@column{#1}}\PT@allcols}}}}%+     \PT@postlazylist+   \fi}+\def\PT@write@column #1#2%+  {\noexpand\maxcolumn^^J%+    {\PT@StripColumn{#2}}%+    {\@nameuse{#2#1}}}%+\def\pboxed{%+   \let\PT@begin       \empty+   \let\PT@end         \empty+   \ifx\\\PT@arraycr+     \let\PT@cr        \PT@normalcr+   \else+     \let\PT@cr        \\%+   \fi+   \expandafter\beginpolytable\ignorespaces}++\let\endpboxed\endpolytable++\def\ptboxed{%+   \def\PT@begin       {\tabular{@{}l@{}}}%+   \let\PT@end         \endtabular+   \let\PT@cr          \@arraycr+   \expandafter\beginpolytable\ignorespaces}++\let\endptboxed\endpolytable++\def\pmboxed{%+   \def\PT@begin       {\array{@{}l@{}}}%+   \let\PT@end         \endarray+   \let\PT@cr          \@arraycr+   \expandafter\beginpolytable\ignorespaces}++\let\endpmboxed\endpolytable++\let\ptabular     \ptboxed+\let\endptabular  \endptboxed+\let\parray       \pmboxed+\let\endparray    \endpmboxed++\endinput+%%+%% End of file `polytable.sty'.
+ sorts.snip view
@@ -0,0 +1,16 @@+> quickSort                     :: (Ord a) => [a] -> [a]+> quickSort []                  =  []+> quickSort (a : as)            =  quickSort [ b | b <- as, b <= a ]+>                               ++ a : quickSort [ b | b <- as, b > a ]+>+> mergeSort                     :: (Ord a) => [a] -> [a]+> mergeSort []                  =  []+> mergeSort [a]                 =  [a]+> mergeSort as                  =  merge (mergeSort bs) (mergeSort cs)+>     where (bs, cs)            =  splitAt (length as `div` 2) as++The worst case execution time of |mergeSort| is $\Theta(n\log n)$.+NB. |splitAt| is given by++< splitAt                       :: Int -> [a] -> ([a], [a])+< splitAt k as                  =  (take k as, drop k as) {-"\enskip."-}
+ spec.snip view
@@ -0,0 +1,24 @@+First, the resulting list must be ordered.+%format a1                      =  "\Varid{a}_1"+%format a2                      =  "\Varid{a}_2"++> ordered                       :: (Ord a) => [a] -> Bool+> ordered []                    =  True+> ordered [a]                   =  True+> ordered (a1 : a2 : as)        =  a1 <= a2 && ordered (a2 : as)++Second, the resulting list must be a rearrangement of the input.++%format Bag.empty               =  "\emptyset "+%format (Bag.single (a))        =  "\mathopen{\lbag}" a "\mathclose{\rbag}"+%format `Bag.union`             =  "\uplus "++< bag                           :: [a] -> Bag a+< bag []                        =  Bag.empty+< bag (a : as)                  =  Bag.single(a) `Bag.union` bag as++Using |ordered| and |bag| we may specify sorting as follows.+%+\begin{equation}+    |ordered (sort M.x) = True /\ bag (sort M.x) = bag M.x| +\end{equation}