packages feed

lhs2tex 1.16 → 1.17

raw patch · 67 files changed

+10094/−9782 lines, 67 filessetup-changed

Files

AUTHORS view
@@ -1,4 +1,5 @@ Ralf Hinze (original version)+Daniel James (improvements to the documentation) Andres Loeh (poly mode, maintainer) Stefan Wehr (adjust patch) Brian Smith (Cabal/Windows patch)
− Auxiliaries.lhs
@@ -1,160 +0,0 @@-%-------------------------------=  ---------------------------------------------\subsection{Auxiliaries}-%-------------------------------=  ----------------------------------------------%if codeOnly || showModuleHeader--> module Auxiliaries            (  module Auxiliaries  )-> where->-> import Data.Char              (  isSpace  )-> import Control.Monad          (  MonadPlus(..)  )-> import Control.Monad.Error--%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-> -}-> instance (Error a, Error b) => Error (a,b) where->-> 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 ++ "}"
+ CHANGELOG view
@@ -0,0 +1,8 @@+Changes (w.r.t. lhs2TeX 1.16)+-----------------------------++* Cabal-1.10 support++* Fix for file permissions problem of installed files++* Several improvements to the documentation
− Directives.lhs
@@ -1,251 +0,0 @@-%-------------------------------=  ---------------------------------------------\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 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                   :: Lang -> String -> Either Exc (String, Equation)-> parseFormat lang s            =  parse lang (equation lang) (convert s)--Format directives. \NB @%format ( = "(\;"@ is legal.--> equation                      :: Lang -> Parser Token (String, Equation)-> equation lang                 =  do (opt, (f, opts, args)) <- optParen lhs->                                     _ <- varsym lang "="->                                     r <- many item->                                     return (f, (opt, opts, args, r))->                               `mplus` do f <- item->                                          _ <- varsym lang "="->                                          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 False->                                        (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 False (Text "_{")]->                                                    ++->                                                    proc_u->                                                    ++->                                                    [TeX False (Text "}")]->         where (t, u)          =  break (== '_') s->               tok_u           =  tokenize lang (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 (const 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                    :: Lang -> String -> Either Exc (String, Subst)-> parseSubst lang s             =  parse lang (substitution lang) (convert s)->-> substitution lang             =  do s <- varid->                                     args <- many varid->                                     _ <- varsym lang "="->                                     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.}-ks, 24.10.2008: A bit messy: For Agda, we explicitly exclude "=" from the set-of varids accepted on the lhs of a directive, because according to the Agda-lexer, "=" is both a varid and a varsym. This shouldn't matter for Haskell,-because "=" will never occur in a Varid constructor.--> varid                         =  do x <- satisfy (\ x -> isVarid x && x /= Varid "="); return (string x)-> conid                         =  do x <- satisfy isConid; return (string x)-> varsym Agda s                 =  satisfy (\ x -> x == Varsym s || x == Varid s) -- Agda has no symbol/id distinction-> varsym Haskell s              =  satisfy (== (Varsym s))->-> isTeX (TeX _ _)               =  True-> isTeX _                       =  False--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Conditional directives}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> type Toggles                  =  FiniteMap Char Value--Auswertung Boole'scher Ausdr"ucke.--> eval                          :: Lang -> Toggles -> String -> Either Exc Value-> eval lang togs                =  parse lang (expression lang togs)->-> expression                    :: Lang -> Toggles -> Parser Token Value-> expression lang togs          =  expr->   where->   expr                        =  do e1 <- appl->                                     e2 <- optional (do op <- varsym' lang; 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                        :: Lang -> Toggles -> String -> Either Exc (String, Value)-> define lang togs              =  parse lang (definition lang togs)->-> definition                    :: Lang -> Toggles -> Parser Token (String, Value)-> definition lang togs          =  do Varid x <- satisfy isVarid->                                     _ <- equal' lang->                                     b <- expression lang togs->                                     return (x, b)--Primitive Parser.--> not',  true', false', open', close'->                               :: Parser Token Token-> equal'                        :: Lang -> Parser Token Token-> equal' lang                   =  varsym lang "="-> not'                          =  satisfy (== (Varid "not"))-> true'                         =  satisfy (== (Conid "True"))-> false'                        =  satisfy (== (Conid "False"))-> open'                         =  satisfy (== (Special '('))-> close'                        =  satisfy (== (Special ')'))--> varsym' lang                  =  do x <- satisfy (isVarsym lang); return (string x)-> isVarsym _ (Varsym _)         =  True-> isVarsym Agda (Varid _)       =  True  -- for Agda-> isVarsym _ _                  =  False-> isString (String _)           =  True-> isString _                    =  False-> isNumeral (Numeral _)         =  True-> isNumeral _                   =  False--Hilfsfunktionen.--> parse                         :: Lang -> Parser Token a -> String -> Either Exc a-> parse lang p str              =  do ts <- tokenize lang str->                                     let ts' = map (\t -> case t of TeX _ x -> TeX False x; _ -> t) .->                                               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
@@ -1,76 +0,0 @@-%-------------------------------=  ---------------------------------------------\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'backquoted a              =  Sub "backquoted" [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'tex a                     =  Sub "tex" [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]
− FileNameUtils.lhs
@@ -1,138 +0,0 @@-> {-# LANGUAGE ScopedTypeVariables #-}->-> module FileNameUtils          ( extension->                               , expandPath->                               , chaseFile->                               , readTextFile->                               , openOutputFile->                               , modifySearchPath->                               , deep, env->                               , absPath->                               , module System.FilePath->                               ) where->-> import Prelude hiding         (  catch, readFile )-> import System.IO              (  openFile, IOMode(..), hSetEncoding, hGetContents, utf8, Handle() )-> import System.Directory-> import System.Environment-> import Data.List-> import Control.Monad (filterM)-> import Control.Exception.Extensible->                               (  try, catch, IOException )-> import System.FilePath-> import System.Info--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              :: [FilePath] -> String -> [FilePath]-> modifySearchPath p np->   | isSearchPathSeparator (head np)                = p ++ split->   | isSearchPathSeparator (last np)                = split ++ p->   | otherwise                                      = split->   where split = splitOn isSearchPathSeparator np--> -- relPath =  joinpath--> -- absPath ps  =  directorySeparator : relPath ps--> isWindows = "win" `isPrefixOf` os || "Win" `isPrefixOf` os || "mingw" `isPrefixOf` os--> absPath                       :: FilePath -> FilePath-> absPath                       =  if isWindows then->                                    (("C:" ++ [pathSeparator]) ++)->                                  else->                                    (pathSeparator :)--> deep                          :: FilePath -> FilePath-> deep                          =  (++(replicate 2 pathSeparator))--> env                           :: String -> FilePath-> env x                         =  "{" ++ x ++ "}"--> extension                     :: FilePath -> Maybe String-> extension fn                  =  case takeExtension fn of->                                    ""       ->  Nothing->                                    (_:ext)  ->  Just ext--> -- dirname = takeDirectory-> -- filename = takeFilePath-> -- basename = takeBaseName--|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 splitSearchPath 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 isPathSeparator 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 </> x)->                                                    . filter ((/='.') . head) . filter (not . null) $ d->                                             d'' <- filterM doesDirectoryExist d'->                                             d''' <- mapM descendFrom d''->                                             return (s : concat d''')->                                        )->                                        (\ (_ :: IOException) -> 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 (\ (_ :: IOException) -> [])->                                                     (map (\x -> a ++ x ++ o) . splitOn isSearchPathSeparator)->                                                     er--> splitOn                       :: (Char -> Bool) -> String -> [String]-> splitOn p s                   =  case dropWhile p s of->                                    "" -> []->                                    s' -> w : splitOn p s''->                                            where (w,s'') = break p s'--> readTextFile                  :: FilePath -> IO String-> readTextFile f                =  do h <- openFile f ReadMode->                                     hSetEncoding h utf8->                                     hGetContents h--> openOutputFile                :: FilePath -> IO Handle-> openOutputFile f              =  do h <- openFile f WriteMode->                                     hSetEncoding h utf8->                                     return h--> chaseFile                     :: [String]    {- search path -}->                               -> FilePath -> IO (String,FilePath)-> chaseFile p fn | isAbsolute fn=  t fn->                | p == []      =  chaseFile ["."] fn->                | otherwise    =  s $ map (\d -> t (md d ++ fn)) p->   where->   md cs | isPathSeparator (last cs)->                               =  cs->         | otherwise           =  addTrailingPathSeparator cs->   t f                         =  catch (readTextFile f >>= \x -> return (x,f))->                                        (\ (_ :: IOException) -> ioError $ userError $ "File `" ++ fn ++ "' not found.\n")->   s []                        =  ioError ->                               $  userError $ "File `" ++ fn ++ "' not found in search path:\n" ++ showpath->   s (x:xs)                    =  catch x (\ (_ :: IOException) -> s xs)->   showpath                    =  concatMap (\x -> "   " ++ x ++ "\n") p
− FiniteMap.lhs
@@ -1,77 +0,0 @@-%-------------------------------=  ---------------------------------------------\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
@@ -1,382 +0,0 @@-%-------------------------------=  ---------------------------------------------\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, isPunctuation  )-> import qualified Data.Char ( isSymbol )-> import Control.Monad-> import Control.Monad.Error ()-> import Document-> import Auxiliaries-> import TeXCommands    (  Lang(..)  )--%endif-A Haskell lexer, based on the Prelude function \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 Bool Doc        -- for inline \TeX (True) and format replacements (False)->                               |  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 True (Text s))    =  "{-\"" ++ s ++ "\"-}"-> string (TeX False (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 ++ "`"--The main function.--> tokenize                      :: Lang -> String -> Either Exc [Token]-> tokenize lang                 =  lift tidyup @@ lift qualify @@ lexify lang--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Phase 1}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---%{-%format lex' = "\Varid{lex}"--ks, 28.08.2008: New: Agda and Haskell modes.--> lexify                        :: Lang -> [Char] -> Either Exc [Token]-> lexify lang []                =  return []-> lexify lang s@(_ : _)         =  case lex' lang s of->     Nothing                   -> Left ("lexical error", s)->     Just (t, s')              -> do ts <- lexify lang s'; return (t : ts)->-> lex'                          :: Lang -> String -> Maybe (Token, String)-> lex' lang ""                  =  Nothing-> lex' lang ('\'' : s)          =  do let (t, u) = lexLitChar s->                                     v <- match "\'" u->                                     return (Char ("'" ++ t ++ "'"), v)-> lex' lang ('"' : s)           =  do let (t, u) = lexLitStr s->                                     v <- match "\"" u->                                     return (String ("\"" ++ t ++ "\""), v)-> lex' lang ('-' : '-' : s)->   | not (null s') && isSymbol lang (head s')->                               =  case s' of->                                    (c : s'') -> return (varsymid lang ("--" ++ d ++ [c]), s'')->   | otherwise                 =  return (Comment t, u)->   where (d, s') = span (== '-') s->         (t, u)  = break (== '\n') s'-> lex' lang ('{' : '-' : '"' : s) ->                               =  do let (t, u) = inlineTeX s->                                     v <- match "\"-}" u->                                     return (TeX True (Text t), v)-> lex' lang ('{' : '-' : '#' : s)->                               =  do let (t, u) = nested 0 s->                                     v <- match "#-}" u->                                     return (Pragma t, v)-> lex' lang ('{' : '-' : s)     =  do let (t, u) = nested 0 s->                                     v <- match "-}" u->                                     return (Nested t, v)-> lex' lang (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 lang) s in return (Conid (c : t), u)->     | isLower c || c == '_'   =  let (t, u) = span (isIdChar lang) s in return (classify (c : t), u)->     | c == ':'                =  let (t, u) = span (isSymbol lang) s in return (consymid lang (c : t), u)->     | isDigit c               =  do let (ds, t) = span isDigit s->                                     (fe, u)  <- lexFracExp t->                                     return (numeral lang (c : ds ++ fe), u)->     | isSymbol lang c         =  let (t, u) = span (isSymbol lang) s in return (varsymid lang (c : t), u)->     | otherwise               =  Nothing->     where->     numeral Agda              =  Varid->     numeral Haskell           =  Numeral->     classify s->         | s `elem` keywords lang->                               =  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->                                     unless (c `elem` "+-") 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)--> varsymid Agda    = Varid-> varsymid Haskell = Varsym-> consymid Agda    = Conid-> consymid Haskell = Consym--%}--\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                     :: Char -> Bool-> isIdChar, isSymbol            :: Lang -> Char -> Bool-> isSpecial c                   =  c `elem` ",;()[]{}`"-> isSymbol Haskell c            =  not (isSpecial c) && notElem c "'\"" &&->                                  (c `elem` "!@#$%&*+./<=>?\\^|:-~" ||->                                   Data.Char.isSymbol c || Data.Char.isPunctuation c)-> isSymbol Agda c               =  isIdChar Agda c-> isIdChar Haskell c            =  isAlphaNum c || c `elem` "_'"-> isIdChar Agda c               =  not (isSpecial c || isSpace c)--> 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|.--Keywords--> keywords                      :: Lang -> [String]-> keywords Haskell              =  [ "case",     "class",    "data",  "default",->                                    "deriving", "do",       "else",  "if",->                                    "import",   "in",       "infix", "infixl",->                                    "infixr",   "instance", "let",   "module",->                                    "newtype",  "of",       "then",  "type",->                                    "where" ]-> keywords Agda                 =  [ "let", "in", "where", "field", "with",->                                    "postulate", "primitive", "open", "import",->                                    "module", "data", "codata", "record", "infix",->                                    "infixl", "infixr", "mutual", "abstract",->                                    "private", "forall", "using", "hiding",->                                    "renaming", "public" ]--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Phase 2}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---Merging qualified names.--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|.--ks, 29.08.2008: Made the non-backwards compatible change to add curly-braces to the set of parentheses. I did this because it's necessary for-Agda, but I also never understood why it isn't the case for Haskell.-This affects spacing of some constructs in Haskell mode, but I think it's-an improvement.--> instance CToken Token where->     catCode (Space _)         =  White->     catCode (Conid _)         =  NoSep->     catCode (Varid _)         =  NoSep->     catCode (Consym _)        =  Sep -- Sep is necessary for correct Haskell formatting->     catCode (Varsym _)        =  Sep -- in Agda mode, Consym/Varsym don't occur->     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
@@ -32,7 +32,7 @@ Unpack the archive. Assume that it has been unpacked into directory "/somewhere". Then say -cd /somewhere/lhs2TeX-1.16+cd /somewhere/lhs2TeX-1.17 ./configure make make install@@ -48,18 +48,18 @@ lhs2TeX binary. The default search path is as follows:  .-{HOME}/lhs2tex-1.16//+{HOME}/lhs2tex-1.17// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.16//+{HOME}/.lhs2tex-1.17// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.16//-/usr/local/share/lhs2tex-1.16//-/usr/local/lib/lhs2tex-1.16//-/usr/share/lhs2tex-1.16//-/usr/lib/lhs2tex-1.16//+/usr/local/share/lhs2tex-1.17//+/usr/local/share/lhs2tex-1.17//+/usr/local/lib/lhs2tex-1.17//+/usr/share/lhs2tex-1.17//+/usr/lib/lhs2tex-1.17// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
− Main.lhs
@@ -1,1012 +0,0 @@-%-------------------------------=  ---------------------------------------------\subsection{Main program}-%-------------------------------=  ----------------------------------------------%if codeOnly || showModuleHeader--> module Main ( main )-> where->-> import Data.Char ( isSpace )-> import Data.List ( isPrefixOf )-> import System.IO-> 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 Prelude hiding ( getContents )->-> -- 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 hSetEncoding stdin  utf8->                                     hSetEncoding stdout utf8->                                     hSetEncoding stderr utf8->                                     (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,->                                          lang       :: Lang,          -- Haskell or Agda, currently->                                          verbose    :: Bool,->                                          searchpath :: [FilePath],->                                          file       :: FilePath,      -- also used for `hugs'->                                          lineno     :: LineNo,->                                          ofile      :: FilePath,->                                          olineno    :: LineNo,->                                          atnewline  :: Bool,->                                          fldir      :: Bool,          -- file/linenumber directives->                                          pragmas    :: Bool,          -- generate LINE pragmas?->                                          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 { lang       = Haskell,->                                          verbose    = False,->                                          searchpath = searchPath,->                                          lineno     = 0,->                                          olineno    = 0,->                                          atnewline  = True,->                                          fldir      = False,->                                          pragmas    = True,->                                          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)]->                               ++ [("lang", Int (fromEnum (lang s)))]->                               ++ [ (decode s, Int (fromEnum s)) | s <- [(minBound :: Style) .. maxBound] ]->                               ++ [ (decode s, Int (fromEnum s)) | s <- [(minBound :: Lang) .. 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 <- openOutputFile f3->                                                             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 <- openOutputFile f3->                                                          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 : _)          =  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 (default)"->   , 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 []    ["haskell"] (NoArg (\s -> return $ s { lang = Haskell}, id, []))         "Haskell lexer (default)"->   , Option []    ["agda"]    (NoArg (\s -> return $ s { lang = Agda}, id, []))            "Agda lexer"->   , Option []    ["pre"]     (NoArg (return, id, [Pre]))                                  "act as ghc preprocessor"->   , Option ['o'] ["output"]  (ReqArg (\f -> (\s -> do h <- openOutputFile f->                                                       return $ s { output = h }, id, [])) "file") "specify output file"->   , Option []    ["file-directives"]->                              (NoArg (\s -> return $ s { fldir = True }, id, []))          "generate %file directives"->   , Option []    ["no-pragmas"]->                              (NoArg (\s -> return $ s { pragmas = False }, id, []))       "no LINE pragmas"->   , 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 (lang st)->                                               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->                                     unless (style st `elem` [CodeOnly,NewCode]) $->                                       do result <- external (map unNL s)->                                          inline result-> format (Command Perform s)    =  do st <- fetch->                                     unless (style st `elem` [CodeOnly,NewCode]) $->                                       do result <- external (map unNL s)->                                          update (\st@State{file = f', lineno = l'} ->->                                                    st{file = "<perform>", files = (f', l') : files st})->                                          fromIO (when (verbose st) (hPutStr stderr $ "(" ++ "<perform>"))->                                          formatStr (addEndNL result)->                                          update (\st'@State{files = (f, l) : fs} ->->                                                    st'{file = f, lineno = l, files = fs})->                                          fromIO (when (verbose st) (hPutStrLn stderr $ ")"))->     where->     addEndNL                  =  (++"\n") . unlines . lines--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->                                     unless (style st `elem` [CodeOnly,NewCode]) $->                                       display s-> format (Environment Evaluate s)->                               =  do st <- fetch->                                     unless (style st `elem` [CodeOnly,NewCode]) $->                                       do result <- external s->                                          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 (lang st) s)->                                     store (st{fmts = FM.add b (fmts st)})-> format (Directive Subst s)    =  do st <- fetch->                                     b <- fromEither (parseSubst (lang st) 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 (lang st) (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 (lang st) (fmts st) s->         select Math st        =  Math.inline (lang st) (fmts st) (isTrue (toggles st) auto) s->         select Poly st        =  Poly.inline (lang st) (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 (lang st) (fmts st) s; return (d, st)->         select Math st        =  do (d, sts) <- Math.display (lang st) (fmts st) (isTrue (toggles st) auto) (stacks st) (align st) s->                                     return (d, st{stacks = sts})->         select Poly st        =  do (d, pstack') <- Poly.display (lang st) (lineno st + 1) (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 (lang st) (fmts st) s->                                     let p = sub'pragma $ Text ("LINE " ++ show (lineno st + 1) ++ " " ++ show (takeFileName $ file st))->                                     return ((if pragmas st then ((p <> sub'nl) <>) else id) 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                     :: Lang -> Directive -> String ->                               -> (FilePath,LineNo) -> [CondInfo] -> Toggles->                               -> [Numbered Class] -> Formatter-> directive lang d s (f,l) stack togs ts->                               =  dir d s stack->   where->   dir If s bs                 =  do b <- fromEither (eval lang togs s)->                                     skipOrFormat ((f, l, bool b, True) : bs) ts->   dir Elif s ((f,l,b2,b1):bs) =  do b <- fromEither (eval lang 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                          =  all (\(_,_,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" `isPrefixOf` 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->                                       -- hPutStrLn stderr ("sending: " ++ script)->                                       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->                                      -- hPutStrLn stderr ("received: " ++ l)->                                      let n'  |  (null . snd . breaks (isPrefixOf magic)) l  =  n->                                              |  otherwise                                   =  n - 1->                                      fmap (l:) (readMagic n')--> extract                       :: String -> String-> extract s                     =  v->     where (t, u)              =  breaks (isPrefixOf 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 (isPrefixOf (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-2010 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
@@ -1,14 +1,14 @@  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+main            := src/Main.lhs+psources        := $(main) src/TeXCommands.lhs src/TeXParser.lhs \+		   src/Typewriter.lhs src/Math.lhs src/MathPoly.lhs \+                   src/MathCommon.lhs src/NewCode.lhs \+		   src/Directives.lhs src/HsLexer.lhs src/FileNameUtils.lhs \+		   src/Parser.lhs src/FiniteMap.lhs src/Auxiliaries.lhs \+		   src/StateT.lhs src/Document.lhs src/Verbatim.lhs src/Value.lhs+sources         := $(psources) src/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)@@ -106,7 +106,7 @@ 	./lhs2TeX --code lhs2TeX.fmt.lit > lhs2TeX.fmt  lhs2TeX : $(sources)-	$(GHC) $(GHCFLAGS) --make -o lhs2TeX $(main)+	$(GHC) $(GHCFLAGS) -isrc --make -o lhs2TeX $(main)  doc : bin 	cd doc; $(MAKE)@@ -161,18 +161,20 @@ srcdist : INSTALL doc 	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi 	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/src 	$(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 $(psources) src/Version.lhs.in $(DISTDIR)/src+	$(INSTALL) -m 644 $(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)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG $(DISTDIR) 	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \ 		> $(DISTDIR)/INSTALL 	chmod 644 $(DISTDIR)/INSTALL@@ -202,7 +204,7 @@ 	$(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)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG $(DISTDIR) 	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \ 		> $(DISTDIR)/INSTALL 	chmod 644 $(DISTDIR)/INSTALL
− Math.lhs
@@ -1,237 +0,0 @@-%-------------------------------=  ---------------------------------------------\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-> import TeXCommands ( Lang(..) )--%endif--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Inline and display code}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> inline                        :: Lang -> Formats -> Bool -> String -> Either Exc Doc-> inline lang fmts auto         =  fmap unNL->                               .> tokenize lang->                               @> 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                       :: Lang -> Formats -> Bool -> (Stack, Stack) -> Maybe Int->                               -> String -> Either Exc (Doc, (Stack,Stack))-> display lang fmts auto sts col=  lift trim->                               @> lift (expand 0)->                               @> tokenize lang->                               @> 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 False 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 False sub'space) : t : before False ts->         Keyword _             -> fromToken (TeX False sub'space) : t : after ts->         _                     -> fromToken (TeX False 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
@@ -1,224 +0,0 @@-%-------------------------------=  ---------------------------------------------\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->-> import Control.Monad--> 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)--> pos2string :: Pos a -> String-> pos2string (Pos r c _) = "'" ++ show r ++ "_" ++ show c--%}--> 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 (Pos tok) -> [Pos tok]-> substitute d auto chunk       =  snd (eval chunk)->   where->   eval                        :: (CToken tok) => [Item (Pos tok)] -> (Mode,[Pos tok])->   eval [e]                    =  eval' e->   eval chunk                  =  (Optional False, concat [ snd (eval' i) | i <- chunk ])->->   eval'                       :: (CToken tok) => Item (Pos tok) -> (Mode,[Pos tok])->   eval' (Delim s)             =  (Optional False, [s])->   eval' (Apply [])            =  impossible "eval'"->   eval' (Apply (e : es))      =  eval'' False e es->->   eval''                      :: (CToken tok) => Bool -> Atom (Pos tok) -> [Atom (Pos tok)] -> (Mode,[Pos tok])->   eval'' _ (Atom s) es        =  case FM.lookup (string (token s) ++ pos2string s) d `mplus` 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 (Pos tok)] -> [Pos tok]->   args es                     =  concat [ sp ++ snd (eval'' False i []) | i <- es ] -- $\cong$ Applikation->   sp                          :: (CToken tok) => [Pos tok]->   sp | auto                   =  [fromToken (TeX False 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
@@ -1,409 +0,0 @@-%-------------------------------=  ---------------------------------------------\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 TeXCommands            (  Lang(..)  )-> -- import Debug.Trace ( trace )--%endif--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Inline and display code}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> inline                        :: Lang -> Formats -> Bool -> String -> Either Exc Doc-> inline lang fmts auto         =  fmap unNL->                               .> tokenize lang->                               @> 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                       :: Lang -> Int -> Formats -> Bool -> Int -> Int -> Stack->                               -> String -> Either Exc (Doc, Stack)-> display lang line fmts auto sep lat stack->                               =  lift trim->                               @> lift (expand 0)->                               @> tokenize lang->                               @> lift (number line 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 False 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 False 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)--The function |isInternal| returns |True| iff the argument is a symbol-or a special internal symbol. See @HsLexer@ for the list of special-symbols.--> 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 (any (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 False 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 False sub'space) : t : before False ts->         Keyword _             -> fromToken (TeX False sub'space) : t : after ts->         _                     -> fromToken (TeX False 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 False (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
@@ -1,104 +0,0 @@-%-------------------------------=  ---------------------------------------------\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 )-> import TeXCommands            (  Lang(..) )--%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                       :: Lang -> Formats -> String -> Either Exc Doc-> display lang fmts             =  lift trim->                               @> lift (expand 0)->                               @> tokenize lang->                               @> 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 False d)       =  d->     tex _ (TeX True d)        =  sub'tex 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) (sub'backquoted (tex Empty t'))->         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
@@ -1,85 +0,0 @@-%-------------------------------=  ---------------------------------------------\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
@@ -1,56 +0,0 @@--                     lhs2TeX version 1.16-                     ====================--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.15)--------------------------------* Fixes for UTF8 and ghc-6.12--* \perform output is now run through lhs2TeX again--* Some smaller bugfixes--Requirements and Download----------------------------A source distribution is available from--  http://people.cs.uu.nl/andres/lhs2tex/--and, of course, via Hackage:--  http://hackage.haskell.org/package/lhs2tex--Should work on all major platforms, but has mainly been-tested on Linux. Binaries will be made available on request.--You need GHC 6.12 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--  lhs2TeX@andres-loeh.de
Setup.hs view
@@ -9,7 +9,7 @@ import Distribution.PackageDescription (PackageDescription(..)) import Distribution.Simple.InstallDirs                             (InstallDirs(..))-import Distribution.Simple.Program +import Distribution.Simple.Program                             (Program(..),ConfiguredProgram(..),ProgramConfiguration(..),                              ProgramLocation(..),simpleProgram,lookupProgram,                              rawSystemProgramConf)@@ -28,15 +28,14 @@ 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 = 116+numversion = 117 ispre = False-pre = 1+pre = 2  main = defaultMainWithHooks lhs2texHooks @@ -45,7 +44,8 @@ lhs2texBuildInfoFile :: FilePath lhs2texBuildInfoFile = "." `joinFileName` ".setup-lhs2tex-config" -generatedFiles = ["Version.lhs","lhs2TeX.1",+generatedFiles = ["src" `joinFileName` "Version.lhs",+                  "lhs2TeX.1",                   "doc" `joinFileName` "InteractiveHugs.lhs",                   "doc" `joinFileName` "InteractivePre.lhs"] @@ -168,7 +168,7 @@                          callLhs2tex v lbi ["--" ++ incToStyle inc , "-Pdoc" ++ sep, lhs2texDir `joinFileName` snippet]                                            (lhs2texDocDir `joinFileName` s ++ ".tex")                 ) snippets-        callLhs2tex v lbi ["--poly" , "-Pdoc" ++ sep, "doc" `joinFileName` "Guide2.lhs"]+        callLhs2tex v lbi ["--poly" , "-Pdoc" ++ sep, "-Psrc" ++ sep, "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")@@ -191,11 +191,11 @@         createDirectoryIfMissing True dataPref         let lhs2texDir = buildDir lbi `joinFileName` lhs2tex         -- lhs2TeX.{fmt,sty}-        mapM_ (\f -> copyFileVerbose v (lhs2texDir `joinFileName` f) (dataPref `joinFileName` f))+        mapM_ (\f -> installOrdinaryFile 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))+        mapM_ (\f -> installOrdinaryFile v ("Library" `joinFileName` f) (dataPref `joinFileName` f))               fmts         -- documentation difficult due to lack of docdir         let lhs2texDocDir = lhs2texDir `joinFileName` "doc"@@ -206,10 +206,10 @@                        then dataPref `joinFileName` "Documentation"                        else datadir (absoluteInstallDirs pd lbi cd) `joinFileName` ".." `joinFileName` "man" `joinFileName` "man1"         createDirectoryIfMissing True docDir-        copyFileVerbose v (lhs2texDocDir `joinFileName` "Guide2.pdf") (docDir `joinFileName` "Guide2.pdf")+        installOrdinaryFile v (lhs2texDocDir `joinFileName` "Guide2.pdf") (docDir `joinFileName` "Guide2.pdf")         when (not isWindows) $           do createDirectoryIfMissing True manDir-             copyFileVerbose v ("lhs2TeX.1") (manDir `joinFileName` "lhs2TeX.1")+             installOrdinaryFile v ("lhs2TeX.1") (manDir `joinFileName` "lhs2TeX.1")         -- polytable         case (installPolyTable ebi) of           Just texmf -> do  let texmfDir = texmf@@ -218,8 +218,8 @@                             createDirectoryIfMissing True ptDir                             stys <- fmap (filter (".sty" `isSuffixOf`))                                          (getDirectoryContents "polytable")-                            mapM_ (\f -> copyFileVerbose v ("polytable" `joinFileName` f)-                                                           (ptDir `joinFileName` f))+                            mapM_ (\f -> installOrdinaryFile v ("polytable" `joinFileName` f)+                                                               (ptDir `joinFileName` f))                                   stys           Nothing    -> return () @@ -291,9 +291,9 @@              do  let mProg = lookupProgram (simpleProgram progName) programConf                  case mProg of                    Just (ConfiguredProgram { programLocation = UserSpecified p,-                                             programArgs = args })  -> return (p,args)+                                             programDefaultArgs = args })  -> return (p,args)                    Just (ConfiguredProgram { programLocation = FoundOnSystem p,-                                             programArgs = args })  -> return (p,args)+                                             programDefaultArgs = args })  -> return (p,args)                    _ -> (die (progName ++ " command not found"))  -- | Run a command in a specific environment and return the output and errors.
− StateT.lhs
@@ -1,70 +0,0 @@-%-------------------------------=  ---------------------------------------------\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
− TeXCommands.lhs
@@ -1,104 +0,0 @@-%-------------------------------=  ---------------------------------------------\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--These don't really belong into a module named TeXCommands:--> data Style                    =  Version | Help | SearchPath | Copying | Warranty | CodeOnly | NewCode | Verb | Typewriter | Poly | Math | Pre->                                  deriving (Eq, Show, Enum, Bounded)--> data Lang                     =  Haskell | Agda->                                  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 Lang where->     representation            =  [ ("haskell", Haskell), ("agda", Agda) ]-> 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
@@ -1,244 +0,0 @@-%-------------------------------=  ---------------------------------------------\subsection{Pseudo-\TeX\ Parser}-%-------------------------------=  ----------------------------------------------%if codeOnly || showModuleHeader--> module TeXParser              (  texparse  )-> where-> import Data.Char              (  isSpace, isAlpha  )-> import TeXCommands-> import Data.List              (  isPrefixOf  )-> 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          =  isPrefixOf 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->     ([], '%' : t)             -> Many "\\%" : classify t->     _                         -> 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
@@ -1,14 +1,14 @@  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+main            := src/Main.lhs+psources        := $(main) src/TeXCommands.lhs src/TeXParser.lhs \+		   src/Typewriter.lhs src/Math.lhs src/MathPoly.lhs \+                   src/MathCommon.lhs src/NewCode.lhs \+		   src/Directives.lhs src/HsLexer.lhs src/FileNameUtils.lhs \+		   src/Parser.lhs src/FiniteMap.lhs src/Auxiliaries.lhs \+		   src/StateT.lhs src/Document.lhs src/Verbatim.lhs src/Value.lhs+sources         := $(psources) src/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)@@ -106,7 +106,7 @@ 	./lhs2TeX --code lhs2TeX.fmt.lit > lhs2TeX.fmt  lhs2TeX : $(sources)-	$(GHC) $(GHCFLAGS) --make -o lhs2TeX $(main)+	$(GHC) $(GHCFLAGS) -isrc --make -o lhs2TeX $(main)  doc : bin 	cd doc; $(MAKE)@@ -161,18 +161,20 @@ srcdist : INSTALL doc 	if test -d $(DISTDIR); then $(RM) -rf $(DISTDIR); fi 	$(MKINSTDIR) $(DISTDIR)+	$(MKINSTDIR) $(DISTDIR)/src 	$(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 $(psources) src/Version.lhs.in $(DISTDIR)/src+	$(INSTALL) -m 644 $(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)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG $(DISTDIR) 	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \ 		> $(DISTDIR)/INSTALL 	chmod 644 $(DISTDIR)/INSTALL@@ -202,7 +204,7 @@ 	$(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)+	$(INSTALL) -m 644 TODO AUTHORS LICENSE CHANGELOG $(DISTDIR) 	cat INSTALL | sed -e "s/@ProgramVersion@/$(PACKAGE_VERSION)/" \ 		> $(DISTDIR)/INSTALL 	chmod 644 $(DISTDIR)/INSTALL
− Typewriter.lhs
@@ -1,97 +0,0 @@-%-------------------------------=  ---------------------------------------------\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-> import TeXCommands ( Lang (..) )--%endif--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Inline and display code}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> inline, display               :: Lang -> Formats -> String -> Either Exc Doc-> inline lang dict              =  tokenize lang->                               @> lift (latexs sub'thin sub'thin dict)->                               @> lift sub'inline--> display lang dict             =  lift trim->                               @> lift (expand 0)->                               @> tokenize lang->                               @> 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 False d)       =  d->     tex _ (TeX True d)        =  sub'tex 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) (sub'backquoted (tex Empty t'))->         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
@@ -1,86 +0,0 @@-%-------------------------------=  ---------------------------------------------\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
@@ -1,81 +0,0 @@-%-------------------------------=  ---------------------------------------------\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
@@ -1,58 +0,0 @@-%if doc-\newcommand\ProgramVersion{@VERSION@}-%else-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Program version information}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> module Version where->-> import FileNameUtils-> import Data.List-> import System.Info->-> version                       :: String-> version                       =  "@VERSION@"-> numversion                    :: Int-> numversion                    =  @NUMVERSION@--Used internally to distinguish prereleases.--> pre                           :: Int-> pre                           =  @PRE@--> isWindows = "win" `isPrefixOf` os || "Win" `isPrefixOf` os--% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - --\subsubsection{Search path}-% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - ---> searchPath                    =  "." :->                                  [  deep (joinPath (env "HOME" : [p ++ x]))->                                  |  p <- ["","."]->                                  ,  x <- lhs2TeXNames->                                  ] ++->                                  [deep (joinPath [env "LHS2TEX"])] ++->                                  [deep stydir] ++->                                  [  deep (path [dir])->                                  |  dir  <-  lhs2TeXNames->                                  ,  path <-  if isWindows then [] else->                                              [\x -> absPath (joinPath $ ["usr","local","share"] ++ x)->                                              ,\x -> absPath (joinPath $ ["usr","local","lib"] ++ x)->                                              ,\x -> absPath (joinPath $ ["usr","share"] ++ x)->                                              ,\x -> absPath (joinPath $ ["usr","lib"] ++ x)->                                              ]->                                  ]->-> lhs2TeXNames                  :: [FilePath]-> lhs2TeXNames                  =  ["lhs2tex-@SHORTVERSION@"->                                  ,"lhs2tex"->                                  ,"lhs2TeX"->                                  ]->-> stydir                        =  replace (replace "@stydir@" "datarootdir" "@datarootdir@") "prefix" "@prefix@"->   where replace x w y  |  ("$" ++ w) `isPrefixOf` x = y ++ drop (length w + 1) x->                        |  ("${" ++ w ++ "}") `isPrefixOf` x = y ++ drop (length w + 3) x->                        |  otherwise = x--%endif
configure view
@@ -1,3968 +1,3961 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.63 for lhs2tex 1.16.-#-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,-# 2002, 2003, 2004, 2005, 2006, 2007, 2008 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=:-  # Pre-4.2 versions of Zsh do 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--as_nl='-'-export as_nl-# Printing a long string crashes Solaris 7 /usr/bin/printf.-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo-if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then-  as_echo='printf %s\n'-  as_echo_n='printf %s'-else-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'-    as_echo_n='/usr/ucb/echo -n'-  else-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'-    as_echo_n_body='eval-      arg=$1;-      case $arg in-      *"$as_nl"*)-	expr "X$arg" : "X\\(.*\\)$as_nl";-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;-      esac;-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"-    '-    export as_echo_n_body-    as_echo_n='sh -c $as_echo_n_body as_echo'-  fi-  export as_echo_body-  as_echo='sh -c $as_echo_body as_echo'-fi--# The user is always right.-if test "${PATH_SEPARATOR+set}" != set; then-  PATH_SEPARATOR=:-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||-      PATH_SEPARATOR=';'-  }-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.)-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-  $as_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.-LC_ALL=C-export LC_ALL-LANGUAGE=C-export LANGUAGE--# 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 ||-$as_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=:-  # Pre-4.2 versions of Zsh do 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=:-  # Pre-4.2 versions of Zsh do 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 bug-autoconf@gnu.org about your system,-  echo including any error possibly output before this message.-  echo This can help us improve future autoconf versions.-  echo Configuration will now proceed without shell functions.-}----  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" ||-    { $as_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 2>/dev/null-fi-if (echo >conf$$.file) 2>/dev/null; then-  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-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.16'-PACKAGE_STRING='lhs2tex 1.16'-PACKAGE_BUGREPORT=''--ac_subst_vars='LTLIBOBJS-LIBOBJS-LHS2TEX-stydir-MKTEXLSR-POLYTABLE_INSTALL-texmf-KPSEWHICH-DVIPS-GV-XDVI-PDFLATEX-LATEX-FIND-UNIQ-SORT-SED-GREP-DIFF-TOUCH-MKDIR-RM-CP-MV-LN_S-INSTALL_DATA-INSTALL_SCRIPT-INSTALL_PROGRAM-HUGS-GHC-PRE-NUMVERSION-SHORTVERSION-VERSION-target_alias-host_alias-build_alias-LIBS-ECHO_T-ECHO_N-ECHO_C-DEFS-mandir-localedir-libdir-psdir-pdfdir-dvidir-htmldir-infodir-docdir-oldincludedir-includedir-localstatedir-sharedstatedir-sysconfdir-datadir-datarootdir-libexecdir-sbindir-bindir-program_transform_name-prefix-exec_prefix-PACKAGE_BUGREPORT-PACKAGE_STRING-PACKAGE_VERSION-PACKAGE_TARNAME-PACKAGE_NAME-PATH_SEPARATOR-SHELL'-ac_subst_files=''-ac_user_opts='-enable_option_checking-with_texmf-enable_polytable-'-      ac_precious_vars='build_alias-host_alias-target_alias'---# Initialize some variables set by options.-ac_init_help=-ac_init_version=false-ac_unrecognized_opts=-ac_unrecognized_sep=-# 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_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`-    # Reject names that are not valid shell variable names.-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&-      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2-   { (exit 1); exit 1; }; }-    ac_useropt_orig=$ac_useropt-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`-    case $ac_user_opts in-      *"-"enable_$ac_useropt"-"*) ;;-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"-	 ac_unrecognized_sep=', ';;-    esac-    eval enable_$ac_useropt=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_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`-    # Reject names that are not valid shell variable names.-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&-      { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2-   { (exit 1); exit 1; }; }-    ac_useropt_orig=$ac_useropt-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`-    case $ac_user_opts in-      *"-"enable_$ac_useropt"-"*) ;;-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"-	 ac_unrecognized_sep=', ';;-    esac-    eval enable_$ac_useropt=\$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_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`-    # Reject names that are not valid shell variable names.-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&-      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2-   { (exit 1); exit 1; }; }-    ac_useropt_orig=$ac_useropt-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`-    case $ac_user_opts in-      *"-"with_$ac_useropt"-"*) ;;-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"-	 ac_unrecognized_sep=', ';;-    esac-    eval with_$ac_useropt=\$ac_optarg ;;--  -without-* | --without-*)-    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`-    # Reject names that are not valid shell variable names.-    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&-      { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2-   { (exit 1); exit 1; }; }-    ac_useropt_orig=$ac_useropt-    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`-    case $ac_user_opts in-      *"-"with_$ac_useropt"-"*) ;;-      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"-	 ac_unrecognized_sep=', ';;-    esac-    eval with_$ac_useropt=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 ;;--  -*) { $as_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 &&-      { $as_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.-    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2-    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&-      $as_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'`-  { $as_echo "$as_me: error: missing argument to $ac_option" >&2-   { (exit 1); exit 1; }; }-fi--if test -n "$ac_unrecognized_opts"; then-  case $enable_option_checking in-    no) ;;-    fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2-   { (exit 1); exit 1; }; } ;;-    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;-  esac-fi--# Check all directory arguments for consistency.-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-  # Remove trailing slashes.-  case $ac_val in-    */ )-      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`-      eval $ac_var=\$ac_val;;-  esac-  # Be sure to have absolute directory names.-  case $ac_val in-    [\\/$]* | ?:[\\/]* )  continue;;-    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;-  esac-  { $as_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-    $as_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 .` ||-  { $as_echo "$as_me: error: working directory cannot be determined" >&2-   { (exit 1); exit 1; }; }-test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||-  { $as_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 -- "$as_myself" ||-$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \-	 X"$as_myself" : 'X\(//\)[^/]' \| \-	 X"$as_myself" : 'X\(//\)$' \| \-	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||-$as_echo X"$as_myself" |-    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 .."-  { $as_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" || { $as_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.16 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.16:";;-   esac-  cat <<\_ACEOF--Optional Features:-  --disable-option-checking  ignore unrecognized --enable/--with options-  --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" ||-      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && 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=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`-  # A ".." for each directory in $ac_dir_suffix.-  ac_top_builddir_sub=`$as_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-      $as_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.16-generated by GNU Autoconf 2.63--Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,-2002, 2003, 2004, 2005, 2006, 2007, 2008 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.16, which was-generated by GNU Autoconf 2.63.  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=.-  $as_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=`$as_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_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;-      esac-      case $ac_var in #(-      _ | IFS | as_nl) ;; #(-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(-      *) $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=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;-      esac-      $as_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=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;-	esac-	$as_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 &&-      $as_echo "$as_me: caught signal $ac_signal"-    $as_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 an explicitly selected file to automatically selected ones.-ac_site_file1=NONE-ac_site_file2=NONE-if test -n "$CONFIG_SITE"; then-  ac_site_file1=$CONFIG_SITE-elif test "x$prefix" != xNONE; then-  ac_site_file1=$prefix/share/config.site-  ac_site_file2=$prefix/etc/config.site-else-  ac_site_file1=$ac_default_prefix/share/config.site-  ac_site_file2=$ac_default_prefix/etc/config.site-fi-for ac_site_file in "$ac_site_file1" "$ac_site_file2"-do-  test "x$ac_site_file" = xNONE && continue-  if test -r "$ac_site_file"; then-    { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5-$as_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-    { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5-$as_echo "$as_me: loading cache $cache_file" >&6;}-    case $cache_file in-      [\\/]* | ?:[\\/]* ) . "$cache_file";;-      *)                      . "./$cache_file";;-    esac-  fi-else-  { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5-$as_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,)-      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5-$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}-      ac_cache_corrupted=: ;;-    ,set)-      { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5-$as_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-	# differences in whitespace do not lead to failure.-	ac_old_val_w=`echo x $ac_old_val`-	ac_new_val_w=`echo x $ac_new_val`-	if test "$ac_old_val_w" != "$ac_new_val_w"; then-	  { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5-$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}-	  ac_cache_corrupted=:-	else-	  { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5-$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}-	  eval $ac_var=\$ac_old_val-	fi-	{ $as_echo "$as_me:$LINENO:   former value:  \`$ac_old_val'" >&5-$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}-	{ $as_echo "$as_me:$LINENO:   current value: \`$ac_new_val'" >&5-$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}-      fi;;-  esac-  # Pass precious variables to config.status.-  if test "$ac_new_set" = set; then-    case $ac_new_val in-    *\'*) ac_arg=$ac_var=`$as_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-  { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}-  { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5-$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}-  { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5-$as_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.16"-SHORTVERSION="1.16"-NUMVERSION=116-PRE=1------# 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-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_GHC+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $GHC" >&5-$as_echo "$GHC" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "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-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_HUGS+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $HUGS" >&5-$as_echo "$HUGS" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "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-  { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5-$as_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.-# Reject install programs that cannot install multiple files.-{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5-$as_echo_n "checking for a BSD-compatible install... " >&6; }-if test -z "$INSTALL"; then-if test "${ac_cv_path_install+set}" = set; then-  $as_echo_n "(cached) " >&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-	    rm -rf conftest.one conftest.two conftest.dir-	    echo one > conftest.one-	    echo two > conftest.two-	    mkdir conftest.dir-	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&-	      test -s conftest.one && test -s conftest.two &&-	      test -s conftest.dir/conftest.one &&-	      test -s conftest.dir/conftest.two-	    then-	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"-	      break 3-	    fi-	  fi-	fi-      done-    done-    ;;-esac--done-IFS=$as_save_IFS--rm -rf conftest.one conftest.two conftest.dir--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-{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5-$as_echo "$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-{ $as_echo "$as_me:$LINENO: checking whether ln -s works" >&5-$as_echo_n "checking whether ln -s works... " >&6; }-LN_S=$as_ln_s-if test "$LN_S" = "ln -s"; then-  { $as_echo "$as_me:$LINENO: result: yes" >&5-$as_echo "yes" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no, using $LN_S" >&5-$as_echo "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-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_MV+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $MV" >&5-$as_echo "$MV" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "cp", so it can be a program name with args.-set dummy cp; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_CP+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $CP" >&5-$as_echo "$CP" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "rm", so it can be a program name with args.-set dummy rm; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_RM+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $RM" >&5-$as_echo "$RM" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "mkdir", so it can be a program name with args.-set dummy mkdir; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_MKDIR+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $MKDIR" >&5-$as_echo "$MKDIR" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "touch", so it can be a program name with args.-set dummy touch; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_TOUCH+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $TOUCH" >&5-$as_echo "$TOUCH" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "diff", so it can be a program name with args.-set dummy diff; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_DIFF+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $DIFF" >&5-$as_echo "$DIFF" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "grep", so it can be a program name with args.-set dummy grep; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_GREP+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $GREP" >&5-$as_echo "$GREP" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "sed", so it can be a program name with args.-set dummy sed; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_SED+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $SED" >&5-$as_echo "$SED" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "sort", so it can be a program name with args.-set dummy sort; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_SORT+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $SORT" >&5-$as_echo "$SORT" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "uniq", so it can be a program name with args.-set dummy uniq; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_UNIQ+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $UNIQ" >&5-$as_echo "$UNIQ" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "find", so it can be a program name with args.-set dummy find; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_FIND+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $FIND" >&5-$as_echo "$FIND" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "latex", so it can be a program name with args.-set dummy latex; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_LATEX+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $LATEX" >&5-$as_echo "$LATEX" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "pdflatex", so it can be a program name with args.-set dummy pdflatex; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_PDFLATEX+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $PDFLATEX" >&5-$as_echo "$PDFLATEX" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "xdvi", so it can be a program name with args.-set dummy xdvi; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_XDVI+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $XDVI" >&5-$as_echo "$XDVI" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "gv", so it can be a program name with args.-set dummy gv; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_GV+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $GV" >&5-$as_echo "$GV" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---# Extract the first word of "dvips", so it can be a program name with args.-set dummy dvips; ac_word=$2-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_DVIPS+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $DVIPS" >&5-$as_echo "$DVIPS" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "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-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_KPSEWHICH+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $KPSEWHICH" >&5-$as_echo "$KPSEWHICH" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi---if test -z "$texmf"; then-  { $as_echo "$as_me:$LINENO: checking for a texmf tree" >&5-$as_echo_n "checking for a texmf tree... " >&6; }-  # If user did not specify something, try it ourselves-  if test "${ac_cv_texmf_tree+set}" = set; then-  $as_echo_n "(cached) " >&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--  { $as_echo "$as_me:$LINENO: result: $ac_cv_texmf_tree" >&5-$as_echo "$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--  { $as_echo "$as_me:$LINENO: checking for texmf.cnf" >&5-$as_echo_n "checking for texmf.cnf... " >&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-    { $as_echo "$as_me:$LINENO: result: yes" >&5-$as_echo "yes" >&6; }--cat >>confdefs.h <<_ACEOF-#define TEXMF_IS_WEB2C 1-_ACEOF--    texmf_is_web2c=yes-  else-    { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "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--{ $as_echo "$as_me:$LINENO: checking for the polytable package" >&5-$as_echo_n "checking for the polytable package... " >&6; }-if test -x "$KPSEWHICH"; then-  POLYTABLE="`$KPSEWHICH polytable.sty`"-fi-if test -f "$POLYTABLE"; then-  { $as_echo "$as_me:$LINENO: result: $POLYTABLE" >&5-$as_echo "$POLYTABLE" >&6; }-  { $as_echo "$as_me:$LINENO: checking for version of polytable" >&5-$as_echo_n "checking for version of polytable... " >&6; }-  POLYTABLE_VERSION=`$GREP " v.* .polytable. package" $POLYTABLE | $SED -e "s/^.*v\(.*\) .polytable. package.*$/\1/"`-  { $as_echo "$as_me:$LINENO: result: $POLYTABLE_VERSION" >&5-$as_echo "$POLYTABLE_VERSION" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi--  # does polytable need to be installed?-  { $as_echo "$as_me:$LINENO: checking whether polytable needs to be installed" >&5-$as_echo_n "checking whether polytable needs to be installed... " >&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-  { $as_echo "$as_me:$LINENO: result: $POLYTABLE_INSTALL" >&5-$as_echo "$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-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5-$as_echo_n "checking for $ac_word... " >&6; }-if test "${ac_cv_path_MKTEXLSR+set}" = set; then-  $as_echo_n "(cached) " >&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"-    $as_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-  { $as_echo "$as_me:$LINENO: result: $MKTEXLSR" >&5-$as_echo "$MKTEXLSR" >&6; }-else-  { $as_echo "$as_me:$LINENO: result: no" >&5-$as_echo "no" >&6; }-fi----# docdir and expansion-docdir="$datadir/doc/$PACKAGE_TARNAME-$PACKAGE_VERSION"--stydir="$datadir/$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_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5-$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;-      esac-      case $ac_var in #(-      _ | IFS | as_nl) ;; #(-      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(-      *) $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" &&-      { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5-$as_echo "$as_me: updating cache $cache_file" >&6;}-    cat confcache >$cache_file-  else-    { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5-$as_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='-:mline-/\\$/{- N- s,\\\n,,- b mline-}-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=`$as_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_write_fail=0-ac_clean_files_save=$ac_clean_files-ac_clean_files="$ac_clean_files $CONFIG_STATUS"-{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5-$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}-cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-#! $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 || ac_write_fail=1-## --------------------- ##-## 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=:-  # Pre-4.2 versions of Zsh do 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--as_nl='-'-export as_nl-# Printing a long string crashes Solaris 7 /usr/bin/printf.-as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo-as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo-if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then-  as_echo='printf %s\n'-  as_echo_n='printf %s'-else-  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then-    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'-    as_echo_n='/usr/ucb/echo -n'-  else-    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'-    as_echo_n_body='eval-      arg=$1;-      case $arg in-      *"$as_nl"*)-	expr "X$arg" : "X\\(.*\\)$as_nl";-	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;-      esac;-      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"-    '-    export as_echo_n_body-    as_echo_n='sh -c $as_echo_n_body as_echo'-  fi-  export as_echo_body-  as_echo='sh -c $as_echo_body as_echo'-fi--# The user is always right.-if test "${PATH_SEPARATOR+set}" != set; then-  PATH_SEPARATOR=:-  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {-    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||-      PATH_SEPARATOR=';'-  }-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.)-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-  $as_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.-LC_ALL=C-export LC_ALL-LANGUAGE=C-export LANGUAGE--# 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 ||-$as_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" ||-    { $as_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 2>/dev/null-fi-if (echo >conf$$.file) 2>/dev/null; then-  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-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.16, which was-generated by GNU Autoconf 2.63.  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--case $ac_config_files in *"-"*) set x $ac_config_files; shift; ac_config_files=$*;;-esac----cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-# Files that config.status was made for.-config_files="$ac_config_files"--_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1-ac_cs_usage="\-\`$as_me' instantiates files from templates according to the-current configuration.--Usage: $0 [OPTION]... [FILE]...--  -h, --help       print this help, then exit-  -V, --version    print version number and configuration settings, then exit-  -q, --quiet, --silent-                   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_write_fail=1-ac_cs_version="\\-lhs2tex config.status 1.16-configured by $0, generated by GNU Autoconf 2.63,-  with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"--Copyright (C) 2008 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'-test -n "\$AWK" || AWK=awk-_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1-# The default lists apply if the user does not specify any file.-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 )-    $as_echo "$ac_cs_version"; exit ;;-  --debug | --debu | --deb | --de | --d | -d )-    debug=: ;;-  --file | --fil | --fi | --f )-    $ac_shift-    case $ac_optarg in-    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;-    esac-    CONFIG_FILES="$CONFIG_FILES '$ac_optarg'"-    ac_need_defaults=false;;-  --he | --h |  --help | --hel | -h )-    $as_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.-  -*) { $as_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 || ac_write_fail=1-if \$ac_cs_recheck; then-  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion-  shift-  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6-  CONFIG_SHELL='$SHELL'-  export CONFIG_SHELL-  exec "\$@"-fi--_ACEOF-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1-exec 5>>config.log-{-  echo-  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX-## Running $as_me. ##-_ASBOX-  $as_echo "$ac_log"-} >&5--_ACEOF-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-_ACEOF--cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1--# 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" ;;--  *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5-$as_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")-} ||-{-   $as_echo "$as_me: cannot create a temporary directory in ." >&2-   { (exit 1); exit 1; }-}--# Set up the scripts for CONFIG_FILES section.-# No need to generate them if there are no CONFIG_FILES.-# This happens for instance with `./config.status config.h'.-if test -n "$CONFIG_FILES"; then---ac_cr='
'-ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`-if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then-  ac_cs_awk_cr='\\r'-else-  ac_cs_awk_cr=$ac_cr-fi--echo 'BEGIN {' >"$tmp/subs1.awk" &&-_ACEOF---{-  echo "cat >conf$$subs.awk <<_ACEOF" &&-  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&-  echo "_ACEOF"-} >conf$$subs.sh ||-  { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5-$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}-   { (exit 1); exit 1; }; }-ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`-ac_delim='%!_!# '-for ac_last_try in false false false false false :; do-  . ./conf$$subs.sh ||-    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5-$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}-   { (exit 1); exit 1; }; }--  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`-  if test $ac_delim_n = $ac_delim_num; then-    break-  elif $ac_last_try; then-    { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5-$as_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-rm -f conf$$subs.sh--cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&-_ACEOF-sed -n '-h-s/^/S["/; s/!.*/"]=/-p-g-s/^[^!]*!//-:repl-t repl-s/'"$ac_delim"'$//-t delim-:nl-h-s/\(.\{148\}\).*/\1/-t more1-s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/-p-n-b repl-:more1-s/["\\]/\\&/g; s/^/"/; s/$/"\\/-p-g-s/.\{148\}//-t nl-:delim-h-s/\(.\{148\}\).*/\1/-t more2-s/["\\]/\\&/g; s/^/"/; s/$/"/-p-b-:more2-s/["\\]/\\&/g; s/^/"/; s/$/"\\/-p-g-s/.\{148\}//-t delim-' <conf$$subs.awk | sed '-/^[^""]/{-  N-  s/\n//-}-' >>$CONFIG_STATUS || ac_write_fail=1-rm -f conf$$subs.awk-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-_ACAWK-cat >>"\$tmp/subs1.awk" <<_ACAWK &&-  for (key in S) S_is_set[key] = 1-  FS = ""--}-{-  line = $ 0-  nfields = split(line, field, "@")-  substed = 0-  len = length(field[1])-  for (i = 2; i < nfields; i++) {-    key = field[i]-    keylen = length(key)-    if (S_is_set[key]) {-      value = S[key]-      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)-      len += length(value) + length(field[++i])-      substed = 1-    } else-      len += 1 + keylen-  }--  print line-}--_ACAWK-_ACEOF-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1-if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then-  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"-else-  cat-fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \-  || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5-$as_echo "$as_me: error: could not setup config files machinery" >&2;}-   { (exit 1); exit 1; }; }-_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 || ac_write_fail=1-fi # test -n "$CONFIG_FILES"---eval set X "  :F $CONFIG_FILES      "-shift-for ac_tag-do-  case $ac_tag in-  :[FHLC]) ac_mode=$ac_tag; continue;;-  esac-  case $ac_mode$ac_tag in-  :[FHL]*:*);;-  :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5-$as_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 ||-	   { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5-$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;}-   { (exit 1); exit 1; }; };;-      esac-      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; 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 '`-	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'-	`' by configure.'-    if test x"$ac_file" != x-; then-      configure_input="$ac_file.  $configure_input"-      { $as_echo "$as_me:$LINENO: creating $ac_file" >&5-$as_echo "$as_me: creating $ac_file" >&6;}-    fi-    # Neutralize special characters interpreted by sed in replacement strings.-    case $configure_input in #(-    *\&* | *\|* | *\\* )-       ac_sed_conf_input=`$as_echo "$configure_input" |-       sed 's/[\\\\&|]/\\\\&/g'`;; #(-    *) ac_sed_conf_input=$configure_input;;-    esac--    case $ac_tag in-    *:-:* | *:-) cat >"$tmp/stdin" \-      || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5-$as_echo "$as_me: error: could not create $ac_file" >&2;}-   { (exit 1); exit 1; }; } ;;-    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 ||-$as_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=`$as_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 ||-$as_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" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5-$as_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=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`-  # A ".." for each directory in $ac_dir_suffix.-  ac_top_builddir_sub=`$as_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 || ac_write_fail=1-# 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=--ac_sed_dataroot='-/datarootdir/ {-  p-  q-}-/@datadir@/p-/@docdir@/p-/@infodir@/p-/@localedir@/p-/@mandir@/p-'-case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in-*datarootdir*) ac_datarootdir_seen=yes;;-*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)-  { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5-$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}-_ACEOF-cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1-  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 || ac_write_fail=1-ac_sed_extra="$ac_vpsub-$extrasub-_ACEOF-cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1-:t-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b-s|@configure_input@|$ac_sed_conf_input|;t t-s&@top_builddir@&$ac_top_builddir_sub&;t t-s&@top_build_prefix@&$ac_top_build_prefix&;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-"-eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \-  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5-$as_echo "$as_me: error: could not create $ac_file" >&2;}-   { (exit 1); exit 1; }; }--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"; } &&-  { $as_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-$as_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 \-  || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5-$as_echo "$as_me: error: could not create $ac_file" >&2;}-   { (exit 1); exit 1; }; }- ;;----  esac--done # for ac_tag---{ (exit 0); exit 0; }-_ACEOF-chmod +x $CONFIG_STATUS-ac_clean_files=$ac_clean_files_save--test $ac_write_fail = 0 ||-  { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5-$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;}-   { (exit 1); exit 1; }; }---# 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-if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then-  { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5+# Generated by GNU Autoconf 2.68 for lhs2tex 1.17.+#+#+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 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=:+  # Pre-4.2 versions of Zsh do 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_nl='+'+export as_nl+# Printing a long string crashes Solaris 7 /usr/bin/printf.+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo+# Prefer a ksh shell builtin over an external printf program on Solaris,+# but without wasting forks for bash or zsh.+if test -z "$BASH_VERSION$ZSH_VERSION" \+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then+  as_echo='print -r --'+  as_echo_n='print -rn --'+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then+  as_echo='printf %s\n'+  as_echo_n='printf %s'+else+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'+    as_echo_n='/usr/ucb/echo -n'+  else+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'+    as_echo_n_body='eval+      arg=$1;+      case $arg in #(+      *"$as_nl"*)+	expr "X$arg" : "X\\(.*\\)$as_nl";+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;+      esac;+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"+    '+    export as_echo_n_body+    as_echo_n='sh -c $as_echo_n_body as_echo'+  fi+  export as_echo_body+  as_echo='sh -c $as_echo_body as_echo'+fi++# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+  PATH_SEPARATOR=:+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+      PATH_SEPARATOR=';'+  }+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.)+IFS=" ""	$as_nl"++# Find who we are.  Look in the path if we contain no directory separator.+as_myself=+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+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+  exit 1+fi++# Unset variables that we do not need and which cause bugs (e.g. in+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"+# suppresses any "Segmentation fault" message there.  '((' could+# trigger a bug in pdksh 5.2.14.+for as_var in BASH_ENV ENV MAIL MAILPATH+do eval test x\${$as_var+set} = xset \+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done+PS1='$ '+PS2='> '+PS4='+ '++# NLS nuisances.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# CDPATH.+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH++if test "x$CONFIG_SHELL" = x; then+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :+  emulate sh+  NULLCMD=:+  # Pre-4.2 versions of Zsh do 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_required="as_fn_return () { (exit \$1); }+as_fn_success () { as_fn_return 0; }+as_fn_failure () { as_fn_return 1; }+as_fn_ret_success () { return 0; }+as_fn_ret_failure () { return 1; }++exitcode=0+as_fn_success || { exitcode=1; echo as_fn_success failed.; }+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :++else+  exitcode=1; echo positional parameters were not saved.+fi+test x\$exitcode = x0 || exit 1"+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"+  if (eval "$as_required") 2>/dev/null; then :+  as_have_required=yes+else+  as_have_required=no+fi+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :++else+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+as_found=false+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH+do+  IFS=$as_save_IFS+  test -z "$as_dir" && as_dir=.+  as_found=:+  case $as_dir in #(+	 /*)+	   for as_base in sh bash ksh sh5; do+	     # Try only shells that exist, to save several forks.+	     as_shell=$as_dir/$as_base+	     if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&+		    { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :+  CONFIG_SHELL=$as_shell as_have_required=yes+		   if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :+  break 2+fi+fi+	   done;;+       esac+  as_found=false+done+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&+	      { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :+  CONFIG_SHELL=$SHELL as_have_required=yes+fi; }+IFS=$as_save_IFS+++      if test "x$CONFIG_SHELL" != x; then :+  # We cannot yet assume a decent shell, so we have to provide a+	# neutralization value for shells without unset; and this also+	# works around shells that cannot unset nonexistent variables.+	# Preserve -v and -x to the replacement shell.+	BASH_ENV=/dev/null+	ENV=/dev/null+	(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+	export CONFIG_SHELL+	case $- in # ((((+	  *v*x* | *x*v* ) as_opts=-vx ;;+	  *v* ) as_opts=-v ;;+	  *x* ) as_opts=-x ;;+	  * ) as_opts= ;;+	esac+	exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"}+fi++    if test x$as_have_required = xno; then :+  $as_echo "$0: This script requires a shell more modern than all"+  $as_echo "$0: the shells that I found on your system."+  if test x${ZSH_VERSION+set} = xset ; then+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."+  else+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,+$0: including any error possibly output before this+$0: message. Then install a modern shell, or manually run+$0: the script under such a shell if you do have one."+  fi+  exit 1+fi+fi+fi+SHELL=${CONFIG_SHELL-/bin/sh}+export SHELL+# Unset more variables known to interfere with behavior of common tools.+CLICOLOR_FORCE= GREP_OPTIONS=+unset CLICOLOR_FORCE GREP_OPTIONS++## --------------------- ##+## M4sh Shell Functions. ##+## --------------------- ##+# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+  { eval $1=; unset $1;}+}+as_unset=as_fn_unset++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+  return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+  set +e+  as_fn_set_status $1+  exit $1+} # as_fn_exit++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++  case $as_dir in #(+  -*) as_dir=./$as_dir;;+  esac+  test -d "$as_dir" || eval $as_mkdir_p || {+    as_dirs=+    while :; do+      case $as_dir in #(+      *\'*) as_qdir=`$as_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 ||+$as_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" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p+# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :+  eval 'as_fn_append ()+  {+    eval $1+=\$2+  }'+else+  as_fn_append ()+  {+    eval $1=\$$1\$2+  }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :+  eval 'as_fn_arith ()+  {+    as_val=$(( $* ))+  }'+else+  as_fn_arith ()+  {+    as_val=`expr "$@" || test $? -eq 1`+  }+fi # as_fn_arith+++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+  as_status=$1; test $as_status -eq 0 && as_status=1+  if test "$4"; then+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+  fi+  $as_echo "$as_me: error: $2" >&2+  as_fn_exit $as_status+} # as_fn_error++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++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+  as_dirname=dirname+else+  as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+	 X"$0" : 'X\(//\)$' \| \+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||+$as_echo X/"$0" |+    sed '/^.*\/\([^/][^/]*\)\/*$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`++# 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+++  as_lineno_1=$LINENO as_lineno_1a=$LINENO+  as_lineno_2=$LINENO as_lineno_2a=$LINENO+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {+  # 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" ||+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_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+}++ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+  case `echo 'xy\c'` in+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.+  xy)  ECHO_C='\c';;+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null+       ECHO_T='	';;+  esac;;+*)+  ECHO_N='-n';;+esac++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 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+  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+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='mkdir -p "$as_dir"'+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'"+++test -n "$DJDIR" || exec 7<&0 </dev/null+exec 6>&1++# Name of the host.+# hostname on some systems (SVR3.2, old GNU/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=++# Identity of this package.+PACKAGE_NAME='lhs2tex'+PACKAGE_TARNAME='lhs2tex'+PACKAGE_VERSION='1.17'+PACKAGE_STRING='lhs2tex 1.17'+PACKAGE_BUGREPORT=''+PACKAGE_URL=''++ac_subst_vars='LTLIBOBJS+LIBOBJS+LHS2TEX+stydir+MKTEXLSR+POLYTABLE_INSTALL+texmf+KPSEWHICH+DVIPS+GV+XDVI+PDFLATEX+LATEX+FIND+UNIQ+SORT+SED+GREP+DIFF+TOUCH+MKDIR+RM+CP+MV+LN_S+INSTALL_DATA+INSTALL_SCRIPT+INSTALL_PROGRAM+HUGS+GHC+PRE+NUMVERSION+SHORTVERSION+VERSION+target_alias+host_alias+build_alias+LIBS+ECHO_T+ECHO_N+ECHO_C+DEFS+mandir+localedir+libdir+psdir+pdfdir+dvidir+htmldir+infodir+docdir+oldincludedir+includedir+localstatedir+sharedstatedir+sysconfdir+datadir+datarootdir+libexecdir+sbindir+bindir+program_transform_name+prefix+exec_prefix+PACKAGE_URL+PACKAGE_BUGREPORT+PACKAGE_STRING+PACKAGE_VERSION+PACKAGE_TARNAME+PACKAGE_NAME+PATH_SEPARATOR+SHELL'+ac_subst_files=''+ac_user_opts='+enable_option_checking+with_texmf+enable_polytable+'+      ac_precious_vars='build_alias+host_alias+target_alias'+++# Initialize some variables set by options.+ac_init_help=+ac_init_version=false+ac_unrecognized_opts=+ac_unrecognized_sep=+# 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= ;;+  *)    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_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+      as_fn_error $? "invalid feature name: $ac_useropt"+    ac_useropt_orig=$ac_useropt+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`+    case $ac_user_opts in+      *"+"enable_$ac_useropt"+"*) ;;+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"+	 ac_unrecognized_sep=', ';;+    esac+    eval enable_$ac_useropt=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_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+      as_fn_error $? "invalid feature name: $ac_useropt"+    ac_useropt_orig=$ac_useropt+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`+    case $ac_user_opts in+      *"+"enable_$ac_useropt"+"*) ;;+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"+	 ac_unrecognized_sep=', ';;+    esac+    eval enable_$ac_useropt=\$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_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+      as_fn_error $? "invalid package name: $ac_useropt"+    ac_useropt_orig=$ac_useropt+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`+    case $ac_user_opts in+      *"+"with_$ac_useropt"+"*) ;;+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"+	 ac_unrecognized_sep=', ';;+    esac+    eval with_$ac_useropt=\$ac_optarg ;;++  -without-* | --without-*)+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`+    # Reject names that are not valid shell variable names.+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+      as_fn_error $? "invalid package name: $ac_useropt"+    ac_useropt_orig=$ac_useropt+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`+    case $ac_user_opts in+      *"+"with_$ac_useropt"+"*) ;;+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"+	 ac_unrecognized_sep=', ';;+    esac+    eval with_$ac_useropt=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 ;;++  -*) as_fn_error $? "unrecognized option: \`$ac_option'+Try \`$0 --help' for more information"+    ;;++  *=*)+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`+    # Reject names that are not valid shell variable names.+    case $ac_envvar in #(+      '' | [0-9]* | *[!_$as_cr_alnum]* )+      as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;+    esac+    eval $ac_envvar=\$ac_optarg+    export $ac_envvar ;;++  *)+    # FIXME: should be removed in autoconf 3.0.+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&+      $as_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'`+  as_fn_error $? "missing argument to $ac_option"+fi++if test -n "$ac_unrecognized_opts"; then+  case $enable_option_checking in+    no) ;;+    fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;+  esac+fi++# Check all directory arguments for consistency.+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+  # Remove trailing slashes.+  case $ac_val in+    */ )+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`+      eval $ac_var=\$ac_val;;+  esac+  # Be sure to have absolute directory names.+  case $ac_val in+    [\\/$]* | ?:[\\/]* )  continue;;+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;+  esac+  as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"+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+    $as_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 .` ||+  as_fn_error $? "working directory cannot be determined"+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||+  as_fn_error $? "pwd does not report name of working directory"+++# 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 -- "$as_myself" ||+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+	 X"$as_myself" : 'X\(//\)[^/]' \| \+	 X"$as_myself" : 'X\(//\)$' \| \+	 X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||+$as_echo X"$as_myself" |+    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 .."+  as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"+fi+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"+ac_abs_confdir=`(+	cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"+	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.17 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.17:";;+   esac+  cat <<\_ACEOF++Optional Features:+  --disable-option-checking  ignore unrecognized --enable/--with options+  --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]++Report bugs to the package provider.+_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" ||+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && 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=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`+  # A ".." for each directory in $ac_dir_suffix.+  ac_top_builddir_sub=`$as_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+      $as_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.17+generated by GNU Autoconf 2.68++Copyright (C) 2010 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++## ------------------------ ##+## Autoconf initialization. ##+## ------------------------ ##+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.17, which was+generated by GNU Autoconf 2.68.  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=.+    $as_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=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+    esac+    case $ac_pass in+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;+    2)+      as_fn_append 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+      as_fn_append ac_configure_args " '$ac_arg'"+      ;;+    esac+  done+done+{ ac_configure_args0=; unset ac_configure_args0;}+{ ac_configure_args1=; unset 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++    $as_echo "## ---------------- ##+## Cache variables. ##+## ---------------- ##"+    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_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+      esac+      case $ac_var in #(+      _ | IFS | as_nl) ;; #(+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+      *) { eval $ac_var=; 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++    $as_echo "## ----------------- ##+## Output variables. ##+## ----------------- ##"+    echo+    for ac_var in $ac_subst_vars+    do+      eval ac_val=\$$ac_var+      case $ac_val in+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+      esac+      $as_echo "$ac_var='\''$ac_val'\''"+    done | sort+    echo++    if test -n "$ac_subst_files"; then+      $as_echo "## ------------------- ##+## File substitutions. ##+## ------------------- ##"+      echo+      for ac_var in $ac_subst_files+      do+	eval ac_val=\$$ac_var+	case $ac_val in+	*\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+	esac+	$as_echo "$ac_var='\''$ac_val'\''"+      done | sort+      echo+    fi++    if test -s confdefs.h; then+      $as_echo "## ----------- ##+## confdefs.h. ##+## ----------- ##"+      echo+      cat confdefs.h+      echo+    fi+    test "$ac_signal" != 0 &&+      $as_echo "$as_me: caught signal $ac_signal"+    $as_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'; as_fn_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++$as_echo "/* confdefs.h */" > 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++cat >>confdefs.h <<_ACEOF+#define PACKAGE_URL "$PACKAGE_URL"+_ACEOF+++# Let the site file select an alternate cache file if it wants to.+# Prefer an explicitly selected file to automatically selected ones.+ac_site_file1=NONE+ac_site_file2=NONE+if test -n "$CONFIG_SITE"; then+  # We do not want a PATH search for config.site.+  case $CONFIG_SITE in #((+    -*)  ac_site_file1=./$CONFIG_SITE;;+    */*) ac_site_file1=$CONFIG_SITE;;+    *)   ac_site_file1=./$CONFIG_SITE;;+  esac+elif test "x$prefix" != xNONE; then+  ac_site_file1=$prefix/share/config.site+  ac_site_file2=$prefix/etc/config.site+else+  ac_site_file1=$ac_default_prefix/share/config.site+  ac_site_file2=$ac_default_prefix/etc/config.site+fi+for ac_site_file in "$ac_site_file1" "$ac_site_file2"+do+  test "x$ac_site_file" = xNONE && continue+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5+$as_echo "$as_me: loading site script $ac_site_file" >&6;}+    sed 's/^/| /' "$ac_site_file" >&5+    . "$ac_site_file" \+      || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}+as_fn_error $? "failed to load site script $ac_site_file+See \`config.log' for more details" "$LINENO" 5; }+  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.  DJGPP emulates it as a regular file.+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5+$as_echo "$as_me: loading cache $cache_file" >&6;}+    case $cache_file in+      [\\/]* | ?:[\\/]* ) . "$cache_file";;+      *)                      . "./$cache_file";;+    esac+  fi+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5+$as_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,)+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}+      ac_cache_corrupted=: ;;+    ,set)+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5+$as_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+	# differences in whitespace do not lead to failure.+	ac_old_val_w=`echo x $ac_old_val`+	ac_new_val_w=`echo x $ac_new_val`+	if test "$ac_old_val_w" != "$ac_new_val_w"; then+	  { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}+	  ac_cache_corrupted=:+	else+	  { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}+	  eval $ac_var=\$ac_old_val+	fi+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}+	{ $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}+      fi;;+  esac+  # Pass precious variables to config.status.+  if test "$ac_new_set" = set; then+    case $ac_new_val in+    *\'*) ac_arg=$ac_var=`$as_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.+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;+    esac+  fi+done+if $ac_cache_corrupted; then+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}+  as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5+fi+## -------------------- ##+## Main body of script. ##+## -------------------- ##++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.17"+SHORTVERSION="1.17"+NUMVERSION=117+PRE=2++++++# 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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_GHC+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GHC" >&5+$as_echo "$GHC" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_HUGS+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HUGS" >&5+$as_echo "$HUGS" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "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+  as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5+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.+# Reject install programs that cannot install multiple files.+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5+$as_echo_n "checking for a BSD-compatible install... " >&6; }+if test -z "$INSTALL"; then+if ${ac_cv_path_install+:} false; then :+  $as_echo_n "(cached) " >&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+	    rm -rf conftest.one conftest.two conftest.dir+	    echo one > conftest.one+	    echo two > conftest.two+	    mkdir conftest.dir+	    if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&+	      test -s conftest.one && test -s conftest.two &&+	      test -s conftest.dir/conftest.one &&+	      test -s conftest.dir/conftest.two+	    then+	      ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"+	      break 3+	    fi+	  fi+	fi+      done+    done+    ;;+esac++  done+IFS=$as_save_IFS++rm -rf conftest.one conftest.two conftest.dir++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+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5+$as_echo "$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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5+$as_echo_n "checking whether ln -s works... " >&6; }+LN_S=$as_ln_s+if test "$LN_S" = "ln -s"; then+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5+$as_echo "yes" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5+$as_echo "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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_MV+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MV" >&5+$as_echo "$MV" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "cp", so it can be a program name with args.+set dummy cp; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_CP+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CP" >&5+$as_echo "$CP" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "rm", so it can be a program name with args.+set dummy rm; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_RM+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RM" >&5+$as_echo "$RM" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "mkdir", so it can be a program name with args.+set dummy mkdir; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_MKDIR+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR" >&5+$as_echo "$MKDIR" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "touch", so it can be a program name with args.+set dummy touch; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_TOUCH+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TOUCH" >&5+$as_echo "$TOUCH" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "diff", so it can be a program name with args.+set dummy diff; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_DIFF+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DIFF" >&5+$as_echo "$DIFF" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "grep", so it can be a program name with args.+set dummy grep; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_GREP+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5+$as_echo "$GREP" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "sed", so it can be a program name with args.+set dummy sed; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_SED+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5+$as_echo "$SED" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "sort", so it can be a program name with args.+set dummy sort; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_SORT+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SORT" >&5+$as_echo "$SORT" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "uniq", so it can be a program name with args.+set dummy uniq; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_UNIQ+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UNIQ" >&5+$as_echo "$UNIQ" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "find", so it can be a program name with args.+set dummy find; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_FIND+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FIND" >&5+$as_echo "$FIND" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "latex", so it can be a program name with args.+set dummy latex; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_LATEX+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LATEX" >&5+$as_echo "$LATEX" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "pdflatex", so it can be a program name with args.+set dummy pdflatex; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_PDFLATEX+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PDFLATEX" >&5+$as_echo "$PDFLATEX" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "xdvi", so it can be a program name with args.+set dummy xdvi; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_XDVI+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XDVI" >&5+$as_echo "$XDVI" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "gv", so it can be a program name with args.+set dummy gv; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_GV+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GV" >&5+$as_echo "$GV" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++# Extract the first word of "dvips", so it can be a program name with args.+set dummy dvips; ac_word=$2+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_DVIPS+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DVIPS" >&5+$as_echo "$DVIPS" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_KPSEWHICH+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $KPSEWHICH" >&5+$as_echo "$KPSEWHICH" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi+++if test -z "$texmf"; then+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a texmf tree" >&5+$as_echo_n "checking for a texmf tree... " >&6; }+  # If user did not specify something, try it ourselves+  if ${ac_cv_texmf_tree+:} false; then :+  $as_echo_n "(cached) " >&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++  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_texmf_tree" >&5+$as_echo "$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++  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for texmf.cnf" >&5+$as_echo_n "checking for texmf.cnf... " >&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+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5+$as_echo "yes" >&6; }++cat >>confdefs.h <<_ACEOF+#define TEXMF_IS_WEB2C 1+_ACEOF++    texmf_is_web2c=yes+  else+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "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++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the polytable package" >&5+$as_echo_n "checking for the polytable package... " >&6; }+if test -x "$KPSEWHICH"; then+  POLYTABLE="`$KPSEWHICH polytable.sty`"+fi+if test -f "$POLYTABLE"; then+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POLYTABLE" >&5+$as_echo "$POLYTABLE" >&6; }+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version of polytable" >&5+$as_echo_n "checking for version of polytable... " >&6; }+  POLYTABLE_VERSION=`$GREP " v.* .polytable. package" $POLYTABLE | $SED -e "s/^.*v\(.*\) .polytable. package.*$/\1/"`+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POLYTABLE_VERSION" >&5+$as_echo "$POLYTABLE_VERSION" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi++  # does polytable need to be installed?+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether polytable needs to be installed" >&5+$as_echo_n "checking whether polytable needs to be installed... " >&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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POLYTABLE_INSTALL" >&5+$as_echo "$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+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+$as_echo_n "checking for $ac_word... " >&6; }+if ${ac_cv_path_MKTEXLSR+:} false; then :+  $as_echo_n "(cached) " >&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"+    $as_echo "$as_me:${as_lineno-$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+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKTEXLSR" >&5+$as_echo "$MKTEXLSR" >&6; }+else+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5+$as_echo "no" >&6; }+fi++++# docdir and expansion+docdir="$datadir/doc/$PACKAGE_TARNAME-$PACKAGE_VERSION"++stydir="$datadir/$PACKAGE_TARNAME-$PACKAGE_VERSION"+++# lhs2TeX binary path relative to docdir+LHS2TEX="../lhs2TeX"+++ac_config_files="$ac_config_files config.mk src/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_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+      esac+      case $ac_var in #(+      _ | IFS | as_nl) ;; #(+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+      *) { eval $ac_var=; 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+    if test "x$cache_file" != "x/dev/null"; then+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5+$as_echo "$as_me: updating cache $cache_file" >&6;}+      if test ! -f "$cache_file" || test -h "$cache_file"; then+	cat confcache >"$cache_file"+      else+        case $cache_file in #(+        */* | ?:*)+	  mv -f confcache "$cache_file"$$ &&+	  mv -f "$cache_file"$$ "$cache_file" ;; #(+        *)+	  mv -f confcache "$cache_file" ;;+	esac+      fi+    fi+  else+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5+$as_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='+:mline+/\\$/{+ N+ s,\\\n,,+ b mline+}+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=+U=+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=`$as_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.+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'+done+LIBOBJS=$ac_libobjs++LTLIBOBJS=$ac_ltlibobjs++++: "${CONFIG_STATUS=./config.status}"+ac_write_fail=0+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files $CONFIG_STATUS"+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}+as_write_fail=0+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1+#! $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}+export SHELL+_ASEOF+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1+## -------------------- ##+## 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=:+  # Pre-4.2 versions of Zsh do 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_nl='+'+export as_nl+# Printing a long string crashes Solaris 7 /usr/bin/printf.+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo+# Prefer a ksh shell builtin over an external printf program on Solaris,+# but without wasting forks for bash or zsh.+if test -z "$BASH_VERSION$ZSH_VERSION" \+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then+  as_echo='print -r --'+  as_echo_n='print -rn --'+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then+  as_echo='printf %s\n'+  as_echo_n='printf %s'+else+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'+    as_echo_n='/usr/ucb/echo -n'+  else+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'+    as_echo_n_body='eval+      arg=$1;+      case $arg in #(+      *"$as_nl"*)+	expr "X$arg" : "X\\(.*\\)$as_nl";+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;+      esac;+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"+    '+    export as_echo_n_body+    as_echo_n='sh -c $as_echo_n_body as_echo'+  fi+  export as_echo_body+  as_echo='sh -c $as_echo_body as_echo'+fi++# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+  PATH_SEPARATOR=:+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+      PATH_SEPARATOR=';'+  }+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.)+IFS=" ""	$as_nl"++# Find who we are.  Look in the path if we contain no directory separator.+as_myself=+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+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+  exit 1+fi++# Unset variables that we do not need and which cause bugs (e.g. in+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"+# suppresses any "Segmentation fault" message there.  '((' could+# trigger a bug in pdksh 5.2.14.+for as_var in BASH_ENV ENV MAIL MAILPATH+do eval test x\${$as_var+set} = xset \+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done+PS1='$ '+PS2='> '+PS4='+ '++# NLS nuisances.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# CDPATH.+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH+++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+  as_status=$1; test $as_status -eq 0 && as_status=1+  if test "$4"; then+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+  fi+  $as_echo "$as_me: error: $2" >&2+  as_fn_exit $as_status+} # as_fn_error+++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+  return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+  set +e+  as_fn_set_status $1+  exit $1+} # as_fn_exit++# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+  { eval $1=; unset $1;}+}+as_unset=as_fn_unset+# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :+  eval 'as_fn_append ()+  {+    eval $1+=\$2+  }'+else+  as_fn_append ()+  {+    eval $1=\$$1\$2+  }+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :+  eval 'as_fn_arith ()+  {+    as_val=$(( $* ))+  }'+else+  as_fn_arith ()+  {+    as_val=`expr "$@" || test $? -eq 1`+  }+fi # as_fn_arith+++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++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+  as_dirname=dirname+else+  as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+	 X"$0" : 'X\(//\)$' \| \+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||+$as_echo X/"$0" |+    sed '/^.*\/\([^/][^/]*\)\/*$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\/\)$/{+	    s//\1/+	    q+	  }+	  /^X\/\(\/\).*/{+	    s//\1/+	    q+	  }+	  s/.*/./; q'`++# 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++ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+  case `echo 'xy\c'` in+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.+  xy)  ECHO_C='\c';;+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null+       ECHO_T='	';;+  esac;;+*)+  ECHO_N='-n';;+esac++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 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+  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+else+  as_ln_s='cp -p'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null+++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++  case $as_dir in #(+  -*) as_dir=./$as_dir;;+  esac+  test -d "$as_dir" || eval $as_mkdir_p || {+    as_dirs=+    while :; do+      case $as_dir in #(+      *\'*) as_qdir=`$as_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 ||+$as_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" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p+if mkdir -p . 2>/dev/null; then+  as_mkdir_p='mkdir -p "$as_dir"'+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+## ----------------------------------- ##+## Main body of $CONFIG_STATUS script. ##+## ----------------------------------- ##+_ASEOF+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=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.17, which was+generated by GNU Autoconf 2.68.  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++case $ac_config_files in *"+"*) set x $ac_config_files; shift; ac_config_files=$*;;+esac++++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+# Files that config.status was made for.+config_files="$ac_config_files"++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ac_cs_usage="\+\`$as_me' instantiates files and other configuration actions+from templates according to the current configuration.  Unless the files+and actions are specified as TAGs, all are instantiated by default.++Usage: $0 [OPTION]... [TAG]...++  -h, --help       print this help, then exit+  -V, --version    print version number and configuration settings, then exit+      --config     print configuration, then exit+  -q, --quiet, --silent+                   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 the package provider."++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"+ac_cs_version="\\+lhs2tex config.status 1.17+configured by $0, generated by GNU Autoconf 2.68,+  with options \\"\$ac_cs_config\\"++Copyright (C) 2010 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'+test -n "\$AWK" || AWK=awk+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# The default lists apply if the user does not specify any file.+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=`expr "X$1" : 'X\([^=]*\)='`+    ac_optarg=+    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 )+    $as_echo "$ac_cs_version"; exit ;;+  --config | --confi | --conf | --con | --co | --c )+    $as_echo "$ac_cs_config"; exit ;;+  --debug | --debu | --deb | --de | --d | -d )+    debug=: ;;+  --file | --fil | --fi | --f )+    $ac_shift+    case $ac_optarg in+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;+    '') as_fn_error $? "missing file argument" ;;+    esac+    as_fn_append CONFIG_FILES " '$ac_optarg'"+    ac_need_defaults=false;;+  --he | --h |  --help | --hel | -h )+    $as_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.+  -*) as_fn_error $? "unrecognized option: \`$1'+Try \`$0 --help' for more information." ;;++  *) as_fn_append 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 || ac_write_fail=1+if \$ac_cs_recheck; then+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion+  shift+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6+  CONFIG_SHELL='$SHELL'+  export CONFIG_SHELL+  exec "\$@"+fi++_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+exec 5>>config.log+{+  echo+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX+## Running $as_me. ##+_ASBOX+  $as_echo "$ac_log"+} >&5++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1++# 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" ;;+    "src/Version.lhs") CONFIG_FILES="$CONFIG_FILES src/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" ;;++  *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;+  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= ac_tmp=+  trap 'exit_status=$?+  : "${ac_tmp:=$tmp}"+  { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status+' 0+  trap 'as_fn_exit 1' 1 2 13 15+}+# Create a (secure) tmp directory for tmp files.++{+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&+  test -d "$tmp"+}  ||+{+  tmp=./conf$$-$RANDOM+  (umask 077 && mkdir "$tmp")+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5+ac_tmp=$tmp++# Set up the scripts for CONFIG_FILES section.+# No need to generate them if there are no CONFIG_FILES.+# This happens for instance with `./config.status config.h'.+if test -n "$CONFIG_FILES"; then+++ac_cr=`echo X | tr X '\015'`+# On cygwin, bash can eat \r inside `` if the user requested igncr.+# But we know of no other shell where ac_cr would be empty at this+# point, so we can use a bashism as a fallback.+if test "x$ac_cr" = x; then+  eval ac_cr=\$\'\\r\'+fi+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then+  ac_cs_awk_cr='\\r'+else+  ac_cs_awk_cr=$ac_cr+fi++echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&+_ACEOF+++{+  echo "cat >conf$$subs.awk <<_ACEOF" &&+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&+  echo "_ACEOF"+} >conf$$subs.sh ||+  as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`+ac_delim='%!_!# '+for ac_last_try in false false false false false :; do+  . ./conf$$subs.sh ||+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5++  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`+  if test $ac_delim_n = $ac_delim_num; then+    break+  elif $ac_last_try; then+    as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5+  else+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "+  fi+done+rm -f conf$$subs.sh++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&+_ACEOF+sed -n '+h+s/^/S["/; s/!.*/"]=/+p+g+s/^[^!]*!//+:repl+t repl+s/'"$ac_delim"'$//+t delim+:nl+h+s/\(.\{148\}\)..*/\1/+t more1+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/+p+n+b repl+:more1+s/["\\]/\\&/g; s/^/"/; s/$/"\\/+p+g+s/.\{148\}//+t nl+:delim+h+s/\(.\{148\}\)..*/\1/+t more2+s/["\\]/\\&/g; s/^/"/; s/$/"/+p+b+:more2+s/["\\]/\\&/g; s/^/"/; s/$/"\\/+p+g+s/.\{148\}//+t delim+' <conf$$subs.awk | sed '+/^[^""]/{+  N+  s/\n//+}+' >>$CONFIG_STATUS || ac_write_fail=1+rm -f conf$$subs.awk+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+_ACAWK+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&+  for (key in S) S_is_set[key] = 1+  FS = ""++}+{+  line = $ 0+  nfields = split(line, field, "@")+  substed = 0+  len = length(field[1])+  for (i = 2; i < nfields; i++) {+    key = field[i]+    keylen = length(key)+    if (S_is_set[key]) {+      value = S[key]+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)+      len += length(value) + length(field[++i])+      substed = 1+    } else+      len += 1 + keylen+  }++  print line+}++_ACAWK+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"+else+  cat+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \+  || as_fn_error $? "could not setup config files machinery" "$LINENO" 5+_ACEOF++# VPATH may cause trouble with some makes, so we remove sole $(srcdir),+# ${srcdir} and @srcdir@ entries 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[	 ]*=[	 ]*/{+h+s///+s/^/:/+s/[	 ]*$/:/+s/:\$(srcdir):/:/g+s/:\${srcdir}:/:/g+s/:@srcdir@:/:/g+s/^:*//+s/:*$//+x+s/\(=[	 ]*\).*/\1/+G+s/\n//+s/^[^=]*=[	 ]*$//+}'+fi++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+fi # test -n "$CONFIG_FILES"+++eval set X "  :F $CONFIG_FILES      "+shift+for ac_tag+do+  case $ac_tag in+  :[FHLC]) ac_mode=$ac_tag; continue;;+  esac+  case $ac_mode$ac_tag in+  :[FHL]*:*);;+  :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;+  :[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="$ac_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 ||+	   as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;+      esac+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac+      as_fn_append 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 '`+	  $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'+	`' by configure.'+    if test x"$ac_file" != x-; then+      configure_input="$ac_file.  $configure_input"+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5+$as_echo "$as_me: creating $ac_file" >&6;}+    fi+    # Neutralize special characters interpreted by sed in replacement strings.+    case $configure_input in #(+    *\&* | *\|* | *\\* )+       ac_sed_conf_input=`$as_echo "$configure_input" |+       sed 's/[\\\\&|]/\\\\&/g'`;; #(+    *) ac_sed_conf_input=$configure_input;;+    esac++    case $ac_tag in+    *:-:* | *:-) cat >"$ac_tmp/stdin" \+      || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;+    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 ||+$as_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"; as_fn_mkdir_p+  ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`+  # A ".." for each directory in $ac_dir_suffix.+  ac_top_builddir_sub=`$as_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 || ac_write_fail=1+# 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=+ac_sed_dataroot='+/datarootdir/ {+  p+  q+}+/@datadir@/p+/@docdir@/p+/@infodir@/p+/@localedir@/p+/@mandir@/p'+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in+*datarootdir*) ac_datarootdir_seen=yes;;+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}+_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+  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 || ac_write_fail=1+ac_sed_extra="$ac_vpsub+$extrasub+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+:t+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b+s|@configure_input@|$ac_sed_conf_input|;t t+s&@top_builddir@&$ac_top_builddir_sub&;t t+s&@top_build_prefix@&$ac_top_build_prefix&;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+"+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \+  >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5++test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&+  { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&+  { ac_out=`sed -n '/^[	 ]*datarootdir[	 ]*:*=/p' \+      "$ac_tmp/out"`; test -z "$ac_out"; } &&+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'+which seems to be undefined.  Please make sure it is defined" >&5+$as_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 "$ac_tmp/stdin"+  case $ac_file in+  -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;+  *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;+  esac \+  || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ ;;++++  esac++done # for ac_tag+++as_fn_exit 0+_ACEOF+ac_clean_files=$ac_clean_files_save++test $ac_write_fail = 0 ||+  as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5+++# 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 || as_fn_exit 1+fi+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi 
doc/CabalInstallation.lhs view
@@ -4,7 +4,9 @@ \begingroup \let\origtt=\texfamily \def\texfamily{\origtt\makebox[0pt]{\phantom{X}}}+%format ProgramVersion = "\ProgramVersion " \begin{code}+$ cd /somewhere/lhs2TeX-ProgramVersion $ runghc Setup configure $ runghc Setup build $ runghc Setup install
doc/CompleteDirectives.lhs view
@@ -17,9 +17,9 @@ 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(latency)              -- tweak alignment in \textbf{poly} style+dir(separation)     ^^^   -- tweak alignment in \textbf{poly} style+dir(align)                -- set alignment column in \textbf{math} style dir(options)              -- set options for call of external program dir(subst)                -- primitive formatting directive dir(file)                 -- set filename
doc/GroupSyntax.lhs view
@@ -1,8 +1,10 @@ %include tex.fmt %format ... = "\dots "+%format brop = {+%format brcl = }  \begin{code}-dir({)+dir(brop) ...-dir(})+dir(brcl) \end{code}
doc/Guide2.lhs view
@@ -31,1787 +31,2046 @@  \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}\\-  \smaller \tabular{c}-           Computing Laboratory, University of Oxford\\-           Wolfson Building, Parks Road, Oxford, OX1 3QD, England\\-           \verb|ralf.hinze@comlab.ox.ac.uk|-           \endtabular-  \and-  {Andres L\"oh}\\-  \smaller \tabular{c}-           Institute of Information and Computing Sciences\\-           Utrecht University, P.O.~Box 80.089\\-           3508 TB Utrecht, The Netherlands\\-           \verb|andres@cs.uu.nl|-           \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.-The main mode of operation of @lhs2TeX@ is called the-\defined{style}. By default, @lhs2TeX@ operates in-\textbf{poly} style. Other styles can be selected via-command line flags.-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}-The name of the style is also the name of the flag you have-to pass to @lhs2TeX@ in order to activate the style. For example,-call @lhs2TeX --newcode@ to use @lhs2TeX@ in \textbf{newcode}-style.--%%%-%%%--%----------------------------------------------------------------------------\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.2 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. However, in @code@ and @newcode@ mode, the initial-      characters @>@ and @<@ will be replaced by spaces, so you have-      to indent @code@ environments in order to create a properly indented-      Haskell module.)-\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 too 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| \\-@backquoted@ |a| & how to format a backquoted operator |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| \\-@tex@ |a|     & how to format inlines \TeX\ code \\-@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}+%format lhs2TeX = "\textrm{lhs}\textsf{2}\TeX"+\setdefaultitem{\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{Guide to |lhs2TeX|\\+  \smaller (for version \ProgramVersion)}+\author{{Ralf Hinze}\\+  \smaller \tabular{c}+           Computing Laboratory, University of Oxford\\+           %Wolfson Building, Parks Road, Oxford, OX1 3QD, England\\+           \verb|ralf.hinze@comlab.ox.ac.uk|+           \endtabular+  \and+  {Andres L\"oh}\\+  \smaller \tabular{c}+           Well-Typed LLP\\+           %Institute of Information and Computing Sciences\\+           %Utrecht University, P.O.~Box 80.089\\+           %3508 TB Utrecht, The Netherlands\\+           \verb|mail@andres-loeh.de|+           \endtabular}%+\date{\today}+\maketitle++\tableofcontents++%---------------------------------------------------------------------------+\section{About |lhs2TeX|}+\label{sec:about}+%---------------------------------------------------------------------------++The program |lhs2TeX| is a preprocessor that takes a literate Haskell+source file as input (or something sufficiently alike) and produces a+formatted file that can be processed further 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. The main mode of+operation of |lhs2TeX| is called the \textbf{style}. By default,+|lhs2TeX| operates in \textbf{poly} style. Other styles can be+selected via command line flags.+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}+The name of the style is also the name of the flag you have+to pass to |lhs2TeX| in order to activate the style. For example,+call @lhs2TeX --newcode@ to use |lhs2TeX| in \textbf{newcode}+style.++%%%+%%%++%---------------------------------------------------------------------------+\section{Installing |lhs2TeX|}+%---------------------------------------------------------------------------++There are three options for installing |lhs2TeX| (ordered by ease):+\begin{compactitem}+\item Using Hackage+\item Using Cabal.+\item Classic configure/make.+\end{compactitem}++\subsection{Using Hackage to install |lhs2TeX|}++The Haskell Platform~\cite{platform} is the easiest way to get started+with programming Haskell. It is also the easiest way to build,+install, and manage Haskell packages, through Hackage~\cite{hackage}:+\input{HackageInstallation}%+The first command downloads the latest package list, and the second+installs (along with any dependencies) the latest version of+|lhs2TeX|.++\subsection{Using Cabal to install |lhs2TeX|}++If you have downloaded a source distribution, which is a valid Cabal+package, you can install |lhs2TeX| using Cabal (this requires Cabal+1.2 or later). Begin by unpacking the archive. Assuming that it has been unpacked+into directory @/somewhere@, then say+\input{CabalInstallation}%+The install step requires write access to the installation location and+the \LaTeX\ filename database. (Hint: use \texttt{sudo} if necessary.)++\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.)++Begin by unpack the archive. Assuming 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}++There are a couple of library files that come with |lhs2TeX|+(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{How to hit the ground running with |lhs2TeX|}+%---------------------------------------------------------------------------++When run on a literate Haskell source file, |lhs2TeX| classifies the+input into different blocks.++\paragraph{\bf Bird-style code blocks}+%+In the Bird-style of literate Haskell programming, all lines starting+with @>@ are interpreted as code. (To be good literate code, you must+always leave a blank line before and after the code block.)+%+\input{HelloWorldBirdInput}%+%+These lines are considered by |lhs2TeX| as \textbf{code blocks} and+are processed as such.++Lines beginning with @>@ will be treated as code to be formatted by+|lhs2TeX| and code to be compiled by the compiler. If you wish to hide+code from the compiler, but not from |lhs2TeX|, you can flip the @>@+characters around.+%+\input{HelloWorldBirdSpecInput}%+%+There is no change in the output of |lhs2TeX| (with the exception of+code extraction through the \textbf{code} and \textbf{newcode}+styles).++\paragraph{\bf \LaTeX-style code blocks}+%+The \LaTeX-style of literate programming is to surround code blocks+with @\begin{code}@ and @\end{code}@.+%+\input{HelloWorldCodeInput}%+%+These lines will be treated by |lhs2TeX| (and a Haskell compiler) in+the same way as lines beginning with @>@. The equivalent to lines+beginning with @<@, is to surround the lines with @\begin{spec}@ and+@\end{spec}@.+%+\input{HelloWorldSpecInput}%+%+Unlike a Haskell compiler, |lhs2TeX| does not care if both styles of+literate programming are used in the same file. \emph{But}, if you are+using the \textbf{code} and \textbf{newcode} styles to produce Haskell+source files, the initial characters @>@ and @<@ will be replaced by+spaces, which means that you have to indent @code@ environments in+order to create a properly indented Haskell module.++\paragraph{\bf Inline verbatim}+%+Text between two \verb+@+ characters that is not in a code block is+considered inline verbatim. If you actually want a \verb+@+ character+to appear in the text, it needs to be escaped: \verb+@@+. There is no+need to escape \verb+@+'s in code blocks. For example, \verb+@id :: a+-> a@+ appears as @id :: a -> a@.++\paragraph{\bf Inline code}+%++Text between two @|@ characters that is not in a code block is+considered inline code. Again, @|@ characters that should appear+literally outside of code blocks need to be escaped: @||@. For+example, \verb+|id :: a -> a|+ appears as |id :: a -> a|.++\paragraph{\bf Directives}+%+A \verb+%+ that is followed by the name of an |lhs2TeX| directive is+considered as a \textbf{directive} and may cause |lhs2TeX| to take+special actions. Directives are described in detail in+Section~\ref{sec:directives}.++\paragraph{\bf Special commands}+%+Some commands are treated specially, such as occurrences of the+\TeX\ commands @\eval@, @\perform@, @\verb@ or of the \LaTeX\+environment @verbatim@.+%+The treatment of the @\eval@ and @\perform@ commands is covered in+Section~\ref{sec:call-interp}.+%+The @\verb@ command and the @verbatim@ environment are intercepted+by |lhs2TeX|, however, they will behave as they would without+|lhs2TeX|.++\paragraph{\bf Everything else}+%+Everything in the input file that does not fall into one of the above+cases is is classified as \textbf{plain text} and will simply pass+straight through |lhs2TeX|.+++%---------------------------------------------------------------------------+\section{Using |lhs2TeX| with style}+\label{sec:styles}+%---------------------------------------------------------------------------++In this section, we will walk though an example to illustrate how to+utilize the styles of |lhs2TeX|. As we noted in+Section~\ref{sec:about}, |lhs2TeX| operates in the \textbf{poly} style+by default. Appendix~\ref{sec:deprecatedstyles} contains summaries of+the more simplistic and deprecated styles: \textbf{verb}, \textbf{tt}+and \textbf{math}. For each style, there will also be a short summary.+Some of the points listed in the summary are simply defaults for the+particular style and can actually be changed.++%%%+%%%++\subsection{Achieving complex layouts with the ``poly'' style}++The \textbf{poly} style permits multiple alignments and thus it is+possible to construct complex layouts. The style supersedes the+\textbf{math} style and lifts the alignment restrictions that the+\textbf{math} style has.+%+We will demonstrate the \textbf{poly} style with the following example+as our input to |lhs2TeX|:+%+\input{ZipPolyIn}%+%+This results in the following output:+%+\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 its ancestor 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{Customizing the ``poly'' style}++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 the legacy \textbf{tt} style (see+Section~\ref{sec:tt-style}) by choosing a typewriter font again and+using the same symbols that are default in \textbf{tt} style.+%+\input{ZipPolyTT}%+%+The spaces in the code of the source file are \emph{not}+preserved---the alignment is generated by the @polytable@ package.+This is in contrast to the \textbf{tt} style we are imitating, where+the spacing of the output is the spacing of the input.++%%%+%%%++\subsection{Producing code with the ``code'' and ``newcode'' styles}++These two styles are not for producing a \LaTeX\ source file, but+instead are for producing a Haskell file again. Everything that is not+code is thrown away. In addition, the \textbf{newcode} style has a few+extra features. It applies formatting directives, which can 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} where possible.++\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 and 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}+\label{sec:directives}+%---------------------------------------------------------------------------++There are a number of directives that are understood by |lhs2TeX|.+Some of these are specific to styles, and others are ignored in some+styles. 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}+%+Many of these directive will be explained in more detail in the+following sections:+\begin{compactitem}+  \item See Section~\ref{sec:include} for the @%include@ directive.+  \item See Section~\ref{sec:format} for the @%format@ directive.+  \item See Section~\ref{subsec:group-directive} for the @%{@ and @%}@ directives.+  \item See Section~\ref{subsec:poly-alignment} for the @%separation@ and @%latency@ directives.+  \item See Section~\ref{sec:variables} for the @%let@ directive.+  \item See Section~\ref{sec:conditionals} for the @%if@, @%elif@, @%else@ and @%endif@ directives.+  \item See Section~\ref{sec:call-interp} for the @%options@ directive.+  \item See Section~\ref{sec:subst} for the @%subst@ directive.+\end{compactitem}+++%---------------------------------------------------------------------------+\section{Including files}+\label{sec:include}+%---------------------------------------------------------------------------++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}).+%+The include directive causes the indicated file to be read and processed,+exactly as if its contents had been inserted in the current file at that point.+It is the |lhs2TeX| equivalent of the \TeX\ command @\input@.+%+The include mechanism of |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 @polycode.fmt@. You+should include this file at the start of your document:+%+\input{PolyPrelude}+%+This is the appropriate prelude to use for the default \textbf{poly}+style and the \textbf{newcode} style. If you intend to use one of the+other styles, you should instead include the file @lhs2TeX.fmt@.+%+\input{IncludePrelude}%+%+The reason for this is that some of the defaults in @lhs2TeX.fmt@ are+sub-optimal for the \textbf{poly} or \textbf{newcode} styles; the+@polycode.fmt@ prelude file has been tailored specifically for them.++One of the two files @lhs2TeX.fmt@ or @polycode.fmt@ should be+included---directly or indirectly---in every file+to be processed by |lhs2TeX|!++%+\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 still exists for compatibility+reasons, but it is now deprecated; it should \emph{not} be included in+any of your documents anymore.+\end{important}+%++It is perfectly possible to design your own libraries that replace or+extend these basic files and to include these libraries instead. It is+not recommended, though, to edit @polycode.fmt@ or@lhs2TeX.fmt@ 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. In this case, each of the files will be+processed separately by |lhs2TeX|, so you should must include+@polycode.fmt@ (or @lhs2TeX.fmt@) in every single source file.++\begin{important}[Warning]+Note that both @polycode.fmt@ and @lhs2TeX.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}+\label{sec:format}+%---------------------------------------------------------------------------++The @%format@ directive is a powerful tool for transforming the source+file. The complete syntax that is supported by |lhs2TeX| is quite+complex, but we will break it down by looking in detail at many+different use cases.+%+\input{FormatSyntax}%+%++There are three different forms of the formatting statement. The first+can be used to change the appearance of most functions and operators+and a few other symbols (cf. Section~\ref{subsec:format-single}). The+second form is restricted to named identifiers (both qualified and+unqualified, but no symbolic operators); in turn, such formatting+directives can be parametrized (cf.+Section~\ref{subsec:format-param}). Finally, the third form provides a+syntactically lightweight way of formatting certain identifiers using+some heuristics (cf. Section~\ref{subsec:format-implicit}). Let us+begin by looking at the first form.++%%%+%%%++\subsection{Formatting single tokens}+\label{subsec:format-single}++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 are 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 (by overriding, not replacing 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}+\label{subsec:format-param}++Formatting directives can be parametrized. The parameters may occur+one or more times on the right hand side. This form of the format+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 too few arguments as in the text,+a default symbol is substituted (usually a @\cdot@, but that is+customizable, cf. Section~\ref{sec: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 with quotes.++%%%+%%%++\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}+%+In the first line there are no parentheses to drop. In the second+line, the parentheses around the arguments @a@ and @b@ are dropped, as+are the parentheses around the function @ptest@. In the third line,+the source has double parentheses around each argument as well as the+function. One set of parentheses are dropped in each case, except for+the @b@ argument.++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. You can read more about influencing spacing using+formatting directives in Section~\ref{spacing}.++Let us consider another example involving parentheses with the+following input:+%+\input{ParensExample2In}%+%+This results in+%+\begin{colorsurround}+\input{ParensExample2}+\end{colorsurround}+%+In the second format directive we have redefined the eval function to+drop the redundant parentheses.+++%%%+%%%++\subsection{Local formatting directives}+\label{subsec:group-directive}++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 only scope over the+remainder of that group. Groups can also be nested. (Groups in |lhs2TeX|+do not interact with \TeX\ groups, so these different kinds of groups+do not have to occur properly nested.)++Let us demonstrate the effect of groups with the following example input:+%+\input{GroupExampleIn}%+%+This is appears as:+%+\begin{colorsurround}+\input{GroupExample}%+\end{colorsurround}+%+On the first line, the string ``one'' has been formatted in italics as+|lhs2TeX| has treated it, by default, as a Haskell identifier. On the+second line of output, the first format directive from the source file+has come into effect, so ``one'' has been rendered as a numeral in a+sans-serif font. On the third line, the corresponding source is inside+the group and second formatting directive is in effect. Thus, ``one''+has been rendered in a sans-serif font. Finally, on the fourth line,+the group has closed, along with the scope of the second format+directive. The original format directive applies again (as its scope+extends to the end of the source file), thus, ``one'' has again been+rendered as a numeral in a sans-serif font.+++%%%+%%%++\subsection{Implicit formatting}+\label{subsec:format-implicit}++The third syntactic form of the formatting directive, which lacks a+right hand side, can be used to easily format a frequently occurring+special case, where a token is to be given a numeric subscript, or is+primed.+%+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.++Let us demonstrate implicit formatting with the follow input:+%+\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{sec:conditionals}).++%%%+%%%++%---------------------------------------------------------------------------+\section{Alignment in ``poly'' style}+%---------------------------------------------------------------------------++While the ability to transform the appearance of the source file is+probably the most important feature of |lhs2TeX|, certainly the next+most important is the ability to maintain alignment of code elements,+while using a proportional font. ++Using 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 will appear beginning from the same+      vertical axis 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 unintentionally).++%%%+%%%++\subsection{An example}++The following example shows some of the potential. This is the+input:+%+\input{RepAlgIn}%+%+Look at the highlighted (gray) 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.+%+The output looks as follows:+%+\input{RepAlg}%+++%%%+%%%++\subsection{Accidental alignment}++The main danger of the alignment heuristic is that it may result in+some tokens being aligned unintentionally. The following example+contains illustrates this possibility:+%+\input{AccidentalIn}%+%+The gray 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. Another problems is that in this+case the \emph{centering} of the two symbols is destroyed by the+alignment (cf. Section~\ref{centering}). As a result, ``|::|'' 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 produces the correct output:+\input{AccidentalC}%++%%%+%%%++\subsection{The full story}+\label{subsec:poly-alignment}++If you want to customize the alignment behaviour further, 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 can 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 as follows.++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}%+%+The third line, which begins with |x:xs|, is an indented line, but it+does not start at an alignment column from the previous line. Thus,+the second rule applies and it is indented relative to the first+aligned token to the left in the previous line, which is |case|. The+same explanation applies for the pattern |[]|. The indentation of the+line beginning with |_| is an example of the first rule. It is+indented so as to be aligned with the token |[]|.++%%%+%%%++\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{sec: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{sec: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{sec: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{sec: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{sec: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@}+\label{sec:call-interp}+%---------------------------------------------------------------------------++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{sec: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| \\+@backquoted@ |a| & how to format a backquoted operator |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| \\+@tex@ |a|     & how to format inlines \TeX\ code \\+@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.++\bibitem{hackage}+  Hackage+  \url{http://hackage.haskell.org}++\bibitem{platform}+  The Haskell Platform.+  \url{http://hackage.haskell.org/platform/}++\end{thebibliography}++\appendix+\newpage++%---------------------------------------------------------------------------+\section{Deprecated styles}+\label{sec:deprecatedstyles}+%---------------------------------------------------------------------------++In this Appendix, we will cover the styles that were omitted from+Section~\ref{sec:styles}. We will demonstrate them with the same+common example. As before, each style will include a short summary.+Some of the points listed in the summary are simply 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}+\label{sec: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}++%%%+%%%  \end{document} 
doc/Guide2.pdf view

binary file changed (305354 → 388279 bytes)

+ doc/HackageInstallation.lhs view
@@ -0,0 +1,11 @@+%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}+$ cabal update+$ cabal install lhs2tex+\end{code}+\endgroup
+ doc/HelloWorldBirdInput.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>+>> main  ::  IO ()+>> main  =   putStrLn "Hello, world!"+>++\endgroup
+ doc/HelloWorldBirdSpecInput.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>+>< main  ::  IO ()+>< main  =   putStrLn "Hello, world!"+>++\endgroup
+ doc/HelloWorldCodeInput.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\begin{code}+>main  ::  IO ()+>main  =   putStrLn "Hello, world!"+>\end{code}++\endgroup
+ doc/HelloWorldSpecInput.lhs view
@@ -0,0 +1,11 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\begin{spec}+>main  ::  IO ()+>main  =   putStrLn "Hello, world!"+>\end{spec}++\endgroup
doc/Implicit.lhs view
@@ -1,8 +1,10 @@ %include poly.fmt  %format omega = "\omega"-|[omega, omega13, omega13']|\par+|[omega, omega13, omega', omega13']|\par %format omega13-|[omega, omega13, omega13']|\par+|[omega, omega13, omega', omega13']|\par+%format omega'+|[omega, omega13, omega', omega13']|\par %format omega13' |[omega, omega13, omega13']|
doc/ImplicitIn.lhs view
@@ -3,9 +3,11 @@ \let\origtt=\tt \def\tt#1#2{\origtt} >%format omega = "\omega"->|[omega, omega13, omega13']|\par+>|[omega, omega13, omega', omega13']|\par >%format omega13->|[omega, omega13, omega13']|\par+>|[omega, omega13, omega', omega13']|\par+>%format omega'+>|[omega, omega13, omega', omega13']|\par >%format omega13'->|[omega, omega13, omega13']|+>|[omega, omega13, omega', omega13']| \endgroup
doc/Indent1In.lhs view
@@ -11,8 +11,8 @@ \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}+> unionBy           ::  (a -> a -> Bool) -> [a] -> [a] -> [a]+> unionBy eq xs ys  =   xs ++ foldl  {flip (deleteBy eq)}+>                                    {nubBy eq ys} \end{code} \endgroup
doc/Makefile view
@@ -27,7 +27,7 @@ 	$(LN_S) ../polytable/polytable.sty . 	$(LN_S) ../polytable/lazylist.sty . -RawSearchPath.lhs : ../Version.lhs+RawSearchPath.lhs : ../src/Version.lhs 	echo '\begin{code}' > $@ 	$(LHS2TEX) --searchpath >> $@ 	echo '\end{code}' >> $@@@ -57,7 +57,7 @@ 			do $(PDFLATEX) $(PDFLATEX_OPTS) $<; done;'; \  Guide2.tex : Guide2.lhs $(SNIPPETSGD)-	$(LHS2TEX) --poly -P.:.. $< > $@+	$(LHS2TEX) --poly -P.:..:../src: $< > $@  STC.tex : STC.lhs $(SNIPPETSSTC) 	$(LHS2TEX) --poly $< > $@
+ doc/PolyPrelude.lhs view
@@ -0,0 +1,12 @@+%include verbatim.fmt+\begingroup+\let\origtt=\tt+\def\tt#1#2{\origtt}++>\documentclass{article}+>%include polycode.fmt+>\begin{document}+>+>\end{document}++\endgroup
doc/RawSearchPath.lhs view
@@ -1,17 +1,17 @@ \begin{code} .-{HOME}/lhs2tex-1.16//+{HOME}/lhs2tex-1.17// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.16//+{HOME}/.lhs2tex-1.17// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.16//-/usr/local/share/lhs2tex-1.16//-/usr/local/lib/lhs2tex-1.16//-/usr/share/lhs2tex-1.16//-/usr/lib/lhs2tex-1.16//+/usr/local/share/lhs2tex-1.17//+/usr/local/share/lhs2tex-1.17//+/usr/local/lib/lhs2tex-1.17//+/usr/share/lhs2tex-1.17//+/usr/lib/lhs2tex-1.17// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
+ doc/ZipPolyIn.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/polytt.fmt view
@@ -223,7 +223,7 @@ %subst spaces a		= a %subst special a	= a %subst space     	= "\mskip\thickmuskip"-%subst conid a   	= "\text{\texfamily\origcolor{hcolor}{" a "}}"+%subst conid a   	= "\text{\texfamily " a "}" %subst varid a   	= "\text{\texfamily " a "}" %subst consym a  	= "\text{\texfamily " a "}" %subst varsym a  	= "\text{\texfamily " a "}"
lhs2tex.cabal view
@@ -1,18 +1,26 @@-cabal-version:  >=1.6-name:		lhs2tex-version:	1.16-license:	GPL-license-file:	LICENSE-author:		Ralf Hinze <ralf.hinze@comlab.ox.ac.uk>, Andres Loeh <lhs2tex@andres-loeh.de>-maintainer:	Andres Loeh <lhs2tex@andres-loeh.de>-stability:	stable-homepage:	http://www.andres-loeh.de/lhs2tex/-synopsis:	Preprocessor for typesetting Haskell sources with LaTeX-description:	Preprocessor for typesetting Haskell sources with LaTeX+cabal-version:  >=1.10+name:           lhs2tex+version:        1.17+license:        GPL+license-file:   LICENSE+author:         Ralf Hinze <ralf.hinze@comlab.ox.ac.uk>, Andres Loeh <lhs2tex@andres-loeh.de>+maintainer:     Andres Loeh <lhs2tex@andres-loeh.de>+stability:      stable+homepage:       http://www.andres-loeh.de/lhs2tex/+synopsis:       Preprocessor for typesetting Haskell sources with LaTeX+description:    Preprocessor for typesetting Haskell sources with LaTeX category:       Development, Language build-type:     Custom  executable lhs2TeX-  main-is:	Main.lhs-  build-depends:	base >= 4.2 && < 5, regex-compat, mtl, filepath, directory, process, extensible-exceptions+  main-is:              Main.lhs+  hs-source-dirs:       src+  default-language:     Haskell98+  build-depends:        base >= 4.2 && < 5,+                        regex-compat,+                        mtl,+                        filepath,+                        directory,+                        process,+                        extensible-exceptions 
polytable/polytable.pdf view

binary file changed (204282 → 197083 bytes)

polytable/polytable.sty view
@@ -9,7 +9,7 @@  \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{polytable}%-   [2005/04/25 v0.8.2 `polytable' package (Andres Loeh)]+   [2009/11/01 v0.8.4 `polytable' package (Andres Loeh)] \let\PT@original@And\And \RequirePackage{lazylist} \let\PT@And\And@@ -507,7 +507,7 @@ \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}}+  {\Not{\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}%@@ -639,10 +639,10 @@    \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}+   % this is: \PT@Execute{\Map{\PT@savecolumn{\PT@temp}}{\Reverse\PT@allcols}}    \expandafter\PT@Execute\expandafter{\expandafter      \Map\expandafter{\expandafter\PT@savecolumn-       \expandafter{\PT@temp}}\PT@sortedlist}}+       \expandafter{\PT@temp}}{\Reverse\PT@allcols}}} \def\PT@savecolumn#1#2% #1 macro name, #2 column name   {\PT@typeout@{saving column #2 in \string #1 ...}%    \def\PT@temp{#2}%@@ -739,7 +739,7 @@      {\immediate\write\@auxout{%         \gdef\expandafter\noexpand           \csname PT@restore@\romannumeral\PT@table\endcsname-            {\PT@Execute{\Map{\PT@write@column{#1}}\PT@allcols}}}}%+            {\PT@Execute{\Map{\PT@write@column{#1}}{\Reverse\PT@allcols}}}}}%      \PT@postlazylist    \fi} \def\PT@write@column #1#2%
+ src/Auxiliaries.lhs view
@@ -0,0 +1,160 @@+%-------------------------------=  --------------------------------------------+\subsection{Auxiliaries}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Auxiliaries            (  module Auxiliaries  )+> where+>+> import Data.Char              (  isSpace  )+> import Control.Monad          (  MonadPlus(..)  )+> import Control.Monad.Error++%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+> -}+> instance (Error a, Error b) => Error (a,b) where+>+> 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 ++ "}"
+ src/Directives.lhs view
@@ -0,0 +1,251 @@+%-------------------------------=  --------------------------------------------+\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 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                   :: Lang -> String -> Either Exc (String, Equation)+> parseFormat lang s            =  parse lang (equation lang) (convert s)++Format directives. \NB @%format ( = "(\;"@ is legal.++> equation                      :: Lang -> Parser Token (String, Equation)+> equation lang                 =  do (opt, (f, opts, args)) <- optParen lhs+>                                     _ <- varsym lang "="+>                                     r <- many item+>                                     return (f, (opt, opts, args, r))+>                               `mplus` do f <- item+>                                          _ <- varsym lang "="+>                                          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 False+>                                        (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 False (Text "_{")]+>                                                    +++>                                                    proc_u+>                                                    +++>                                                    [TeX False (Text "}")]+>         where (t, u)          =  break (== '_') s+>               tok_u           =  tokenize lang (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 (const 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                    :: Lang -> String -> Either Exc (String, Subst)+> parseSubst lang s             =  parse lang (substitution lang) (convert s)+>+> substitution lang             =  do s <- varid+>                                     args <- many varid+>                                     _ <- varsym lang "="+>                                     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.}+ks, 24.10.2008: A bit messy: For Agda, we explicitly exclude "=" from the set+of varids accepted on the lhs of a directive, because according to the Agda+lexer, "=" is both a varid and a varsym. This shouldn't matter for Haskell,+because "=" will never occur in a Varid constructor.++> varid                         =  do x <- satisfy (\ x -> isVarid x && x /= Varid "="); return (string x)+> conid                         =  do x <- satisfy isConid; return (string x)+> varsym Agda s                 =  satisfy (\ x -> x == Varsym s || x == Varid s) -- Agda has no symbol/id distinction+> varsym Haskell s              =  satisfy (== (Varsym s))+>+> isTeX (TeX _ _)               =  True+> isTeX _                       =  False++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Conditional directives}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> type Toggles                  =  FiniteMap Char Value++Auswertung Boole'scher Ausdr"ucke.++> eval                          :: Lang -> Toggles -> String -> Either Exc Value+> eval lang togs                =  parse lang (expression lang togs)+>+> expression                    :: Lang -> Toggles -> Parser Token Value+> expression lang togs          =  expr+>   where+>   expr                        =  do e1 <- appl+>                                     e2 <- optional (do op <- varsym' lang; 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                        :: Lang -> Toggles -> String -> Either Exc (String, Value)+> define lang togs              =  parse lang (definition lang togs)+>+> definition                    :: Lang -> Toggles -> Parser Token (String, Value)+> definition lang togs          =  do Varid x <- satisfy isVarid+>                                     _ <- equal' lang+>                                     b <- expression lang togs+>                                     return (x, b)++Primitive Parser.++> not',  true', false', open', close'+>                               :: Parser Token Token+> equal'                        :: Lang -> Parser Token Token+> equal' lang                   =  varsym lang "="+> not'                          =  satisfy (== (Varid "not"))+> true'                         =  satisfy (== (Conid "True"))+> false'                        =  satisfy (== (Conid "False"))+> open'                         =  satisfy (== (Special '('))+> close'                        =  satisfy (== (Special ')'))++> varsym' lang                  =  do x <- satisfy (isVarsym lang); return (string x)+> isVarsym _ (Varsym _)         =  True+> isVarsym Agda (Varid _)       =  True  -- for Agda+> isVarsym _ _                  =  False+> isString (String _)           =  True+> isString _                    =  False+> isNumeral (Numeral _)         =  True+> isNumeral _                   =  False++Hilfsfunktionen.++> parse                         :: Lang -> Parser Token a -> String -> Either Exc a+> parse lang p str              =  do ts <- tokenize lang str+>                                     let ts' = map (\t -> case t of TeX _ x -> TeX False x; _ -> t) .+>                                               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
+ src/Document.lhs view
@@ -0,0 +1,76 @@+%-------------------------------=  --------------------------------------------+\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'backquoted a              =  Sub "backquoted" [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'tex a                     =  Sub "tex" [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]
+ src/FileNameUtils.lhs view
@@ -0,0 +1,147 @@+> {-# LANGUAGE ScopedTypeVariables #-}+>+> module FileNameUtils          ( extension+>                               , expandPath+>                               , chaseFile+>                               , readTextFile+>                               , openOutputFile+>                               , modifySearchPath+>                               , deep, env+>                               , absPath+>                               , module System.FilePath+>                               ) where+>+> import Prelude hiding         (  catch, readFile )+> import System.IO              (  openFile, IOMode(..), hPutStrLn, stderr,+>                                  hSetEncoding, hGetContents, utf8, Handle() )+> import System.IO.Error        (  isDoesNotExistError, isPermissionError )+> import System.Directory+> import System.Environment+> import Data.List+> import Control.Monad (filterM)+> import Control.Exception.Extensible+>                               (  try, catch, IOException )+> import System.FilePath+> import System.Info++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              :: [FilePath] -> String -> [FilePath]+> modifySearchPath p np+>   | isSearchPathSeparator (head np)                = p ++ split+>   | isSearchPathSeparator (last np)                = split ++ p+>   | otherwise                                      = split+>   where split = splitOn isSearchPathSeparator np++> -- relPath =  joinpath++> -- absPath ps  =  directorySeparator : relPath ps++> isWindows = "win" `isPrefixOf` os || "Win" `isPrefixOf` os || "mingw" `isPrefixOf` os++> absPath                       :: FilePath -> FilePath+> absPath                       =  if isWindows then+>                                    (("C:" ++ [pathSeparator]) ++)+>                                  else+>                                    (pathSeparator :)++> deep                          :: FilePath -> FilePath+> deep                          =  (++(replicate 2 pathSeparator))++> env                           :: String -> FilePath+> env x                         =  "{" ++ x ++ "}"++> extension                     :: FilePath -> Maybe String+> extension fn                  =  case takeExtension fn of+>                                    ""       ->  Nothing+>                                    (_:ext)  ->  Just ext++> -- dirname = takeDirectory+> -- filename = takeFilePath+> -- basename = takeBaseName++|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 splitSearchPath 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 isPathSeparator 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 </> x)+>                                                    . filter ((/='.') . head) . filter (not . null) $ d+>                                             d'' <- filterM doesDirectoryExist d'+>                                             d''' <- mapM descendFrom d''+>                                             return (s : concat d''')+>                                        )+>                                        (\ (_ :: IOException) -> 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 (\ (_ :: IOException) -> [])+>                                                     (map (\x -> a ++ x ++ o) . splitOn isSearchPathSeparator)+>                                                     er++> splitOn                       :: (Char -> Bool) -> String -> [String]+> splitOn p s                   =  case dropWhile p s of+>                                    "" -> []+>                                    s' -> w : splitOn p s''+>                                            where (w,s'') = break p s'++> readTextFile                  :: FilePath -> IO String+> readTextFile f                =  do h <- openFile f ReadMode+>                                     hSetEncoding h utf8+>                                     hGetContents h++> openOutputFile                :: FilePath -> IO Handle+> openOutputFile f              =  do h <- openFile f WriteMode+>                                     hSetEncoding h utf8+>                                     return h++> chaseFile                     :: [String]    {- search path -}+>                               -> FilePath -> IO (String,FilePath)+> chaseFile p fn | isAbsolute fn=  catch (t fn) (handle fn (err "."))+>                | p == []      =  chaseFile ["."] fn+>                | otherwise    =  s $ map (\ d -> md d ++ fn) p+>   where+>   md cs | isPathSeparator (last cs)+>                               =  cs+>         | otherwise           =  addTrailingPathSeparator cs+>   t f                         =  readTextFile f >>= \x -> return (x,f)+>   s []                        =  err $ " in search path:\n" ++ showpath+>   s (x:xs)                    =  catch (t x) (handle x (s xs))+>   err extra                   =  ioError+>                               $  userError $ "File `" ++ fn ++ "' not found or not readable" ++ extra+>   handle :: FilePath -> IO (String,FilePath) -> IOException -> IO (String,FilePath)+>   handle x k e                =+>                                    if isDoesNotExistError e then k+>                                    else if isPermissionError e then do+>                                      hPutStrLn stderr $ "Warning: could not access " ++ x ++ " due to permission error."+>                                      k+>                                    else ioError e+>   showpath                    =  concatMap (\x -> "   " ++ x ++ "\n") p
+ src/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++%}
+ src/HsLexer.lhs view
@@ -0,0 +1,377 @@+%-------------------------------=  --------------------------------------------+\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, isPunctuation  )+> import qualified Data.Char ( isSymbol )+> import Control.Monad+> import Control.Monad.Error ()+> import Document+> import Auxiliaries+> import TeXCommands    (  Lang(..)  )++%endif+A Haskell lexer, based on the Prelude function \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 Bool Doc        -- for inline \TeX (True) and format replacements (False)+>                               |  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 True (Text s))    =  "{-\"" ++ s ++ "\"-}"+> string (TeX False (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 ++ "`"++The main function.++> tokenize                      :: Lang -> String -> Either Exc [Token]+> tokenize lang                 =  lift tidyup @@ lift qualify @@ lexify lang++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Phase 1}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++%{+%format lex' = "\Varid{lex}"++ks, 28.08.2008: New: Agda and Haskell modes.++> lexify                        :: Lang -> [Char] -> Either Exc [Token]+> lexify lang []                =  return []+> lexify lang s@(_ : _)         =  case lex' lang s of+>     Nothing                   -> Left ("lexical error", s)+>     Just (t, s')              -> do ts <- lexify lang s'; return (t : ts)+>+> lex'                          :: Lang -> String -> Maybe (Token, String)+> lex' lang ""                  =  Nothing+> lex' lang ('\'' : s)          =  do let (t, u) = lexLitChar s+>                                     v <- match "\'" u+>                                     return (Char ("'" ++ t ++ "'"), v)+> lex' lang ('"' : s)           =  do let (t, u) = lexLitStr s+>                                     v <- match "\"" u+>                                     return (String ("\"" ++ t ++ "\""), v)+> lex' lang ('-' : '-' : s)+>   | not (null s') && isSymbol lang (head s')+>                               =  case s' of+>                                    (c : s'') -> return (varsymid lang ("--" ++ d ++ [c]), s'')+>   | otherwise                 =  return (Comment t, u)+>   where (d, s') = span (== '-') s+>         (t, u)  = break (== '\n') s'+> lex' lang ('{' : '-' : '"' : s) +>                               =  do let (t, u) = inlineTeX s+>                                     v <- match "\"-}" u+>                                     return (TeX True (Text t), v)+> lex' lang ('{' : '-' : '#' : s)+>                               =  do let (t, u) = nested 0 s+>                                     v <- match "#-}" u+>                                     return (Pragma t, v)+> lex' lang ('{' : '-' : s)     =  do let (t, u) = nested 0 s+>                                     v <- match "-}" u+>                                     return (Nested t, v)+> lex' lang (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 lang) s in return (Conid (c : t), u)+>     | isLower c || c == '_'   =  let (t, u) = span (isIdChar lang) s in return (classify (c : t), u)+>     | c == ':'                =  let (t, u) = span (isSymbol lang) s in return (consymid lang (c : t), u)+>     | isDigit c               =  do let (ds, t) = span isDigit s+>                                     (fe, u)  <- lexFracExp t+>                                     return (numeral lang (c : ds ++ fe), u)+>     | isSymbol lang c         =  let (t, u) = span (isSymbol lang) s in return (varsymid lang (c : t), u)+>     | otherwise               =  Nothing+>     where+>     numeral Agda              =  Varid+>     numeral Haskell           =  Numeral+>     classify s+>         | s `elem` keywords lang+>                               =  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+>                                     unless (c `elem` "+-") 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)++> varsymid Agda    = Varid+> varsymid Haskell = Varsym+> consymid Agda    = Conid+> consymid Haskell = Consym++%}++\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.++> 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                     :: Char -> Bool+> isIdChar, isSymbol            :: Lang -> Char -> Bool+> isSpecial c                   =  c `elem` ",;()[]{}`"+> isSymbol Haskell c            =  not (isSpecial c) && notElem c "'\"" &&+>                                  (c `elem` "!@#$%&*+./<=>?\\^|:-~" ||+>                                   Data.Char.isSymbol c || Data.Char.isPunctuation c)+> isSymbol Agda c               =  isIdChar Agda c+> isIdChar Haskell c            =  isAlphaNum c || c `elem` "_'"+> isIdChar Agda c               =  not (isSpecial c || isSpace c)++> match                         :: String -> String -> Maybe String+> match p s+>     | p == t                  =  Just u+>     | otherwise               =  Nothing+>     where (t, u)              =  splitAt (length p) s++Keywords++> keywords                      :: Lang -> [String]+> keywords Haskell              =  [ "case",     "class",    "data",  "default",+>                                    "deriving", "do",       "else",  "if",+>                                    "import",   "in",       "infix", "infixl",+>                                    "infixr",   "instance", "let",   "module",+>                                    "newtype",  "of",       "then",  "type",+>                                    "where" ]+> keywords Agda                 =  [ "let", "in", "where", "field", "with",+>                                    "postulate", "primitive", "open", "import",+>                                    "module", "data", "codata", "record", "infix",+>                                    "infixl", "infixr", "mutual", "abstract",+>                                    "private", "forall", "using", "hiding",+>                                    "renaming", "public" ]++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Phase 2}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++Merging qualified names.++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++Join backquoted ids -- because @`Prelude.div`@ is allowed,+we do this after |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++Note: @` div `@ is not joined; in such a case, a+potential format statement @%format `div` = ...@ is ignored.++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|.++ks, 29.08.2008: Made the non-backwards compatible change to add curly+braces to the set of parentheses. I did this because it's necessary for+Agda, but I also never understood why it isn't the case for Haskell.+This affects spacing of some constructs in Haskell mode, but I think it's+an improvement.++> instance CToken Token where+>     catCode (Space _)         =  White+>     catCode (Conid _)         =  NoSep+>     catCode (Varid _)         =  NoSep+>     catCode (Consym _)        =  Sep -- Sep is necessary for correct Haskell formatting+>     catCode (Varsym _)        =  Sep -- in Agda mode, Consym/Varsym don't occur+>     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+
+ src/Main.lhs view
@@ -0,0 +1,1012 @@+%-------------------------------=  --------------------------------------------+\subsection{Main program}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module Main ( main )+> where+>+> import Data.Char ( isSpace )+> import Data.List ( isPrefixOf )+> import System.IO+> 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 Prelude hiding ( getContents )+>+> -- 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 hSetEncoding stdin  utf8+>                                     hSetEncoding stdout utf8+>                                     hSetEncoding stderr utf8+>                                     (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,+>                                          lang       :: Lang,          -- Haskell or Agda, currently+>                                          verbose    :: Bool,+>                                          searchpath :: [FilePath],+>                                          file       :: FilePath,      -- also used for `hugs'+>                                          lineno     :: LineNo,+>                                          ofile      :: FilePath,+>                                          olineno    :: LineNo,+>                                          atnewline  :: Bool,+>                                          fldir      :: Bool,          -- file/linenumber directives+>                                          pragmas    :: Bool,          -- generate LINE pragmas?+>                                          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 { lang       = Haskell,+>                                          verbose    = False,+>                                          searchpath = searchPath,+>                                          lineno     = 0,+>                                          olineno    = 0,+>                                          atnewline  = True,+>                                          fldir      = False,+>                                          pragmas    = True,+>                                          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)]+>                               ++ [("lang", Int (fromEnum (lang s)))]+>                               ++ [ (decode s, Int (fromEnum s)) | s <- [(minBound :: Style) .. maxBound] ]+>                               ++ [ (decode s, Int (fromEnum s)) | s <- [(minBound :: Lang) .. 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 <- openOutputFile f3+>                                                             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 <- openOutputFile f3+>                                                          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 : _)          =  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 (default)"+>   , 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 []    ["haskell"] (NoArg (\s -> return $ s { lang = Haskell}, id, []))         "Haskell lexer (default)"+>   , Option []    ["agda"]    (NoArg (\s -> return $ s { lang = Agda}, id, []))            "Agda lexer"+>   , Option []    ["pre"]     (NoArg (return, id, [Pre]))                                  "act as ghc preprocessor"+>   , Option ['o'] ["output"]  (ReqArg (\f -> (\s -> do h <- openOutputFile f+>                                                       return $ s { output = h }, id, [])) "file") "specify output file"+>   , Option []    ["file-directives"]+>                              (NoArg (\s -> return $ s { fldir = True }, id, []))          "generate %file directives"+>   , Option []    ["no-pragmas"]+>                              (NoArg (\s -> return $ s { pragmas = False }, id, []))       "no LINE pragmas"+>   , 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 (lang st)+>                                               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 ()|   -- @%%@-comments used to be removed+> 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+>                                     unless (style st `elem` [CodeOnly,NewCode]) $+>                                       do result <- external (map unNL s)+>                                          inline result+> format (Command Perform s)    =  do st <- fetch+>                                     unless (style st `elem` [CodeOnly,NewCode]) $+>                                       do result <- external (map unNL s)+>                                          update (\st@State{file = f', lineno = l'} ->+>                                                    st{file = "<perform>", files = (f', l') : files st})+>                                          fromIO (when (verbose st) (hPutStr stderr $ "(" ++ "<perform>"))+>                                          formatStr (addEndNL result)+>                                          update (\st'@State{files = (f, l) : fs} ->+>                                                    st'{file = f, lineno = l, files = fs})+>                                          fromIO (when (verbose st) (hPutStrLn stderr $ ")"))+>     where+>     addEndNL                  =  (++"\n") . unlines . lines++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+>                                     unless (style st `elem` [CodeOnly,NewCode]) $+>                                       display s+> format (Environment Evaluate s)+>                               =  do st <- fetch+>                                     unless (style st `elem` [CodeOnly,NewCode]) $+>                                       do result <- external s+>                                          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 (lang st) s)+>                                     store (st{fmts = FM.add b (fmts st)})+> format (Directive Subst s)    =  do st <- fetch+>                                     b <- fromEither (parseSubst (lang st) 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: I 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 (lang st) (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 (lang st) (fmts st) s+>         select Math st        =  Math.inline (lang st) (fmts st) (isTrue (toggles st) auto) s+>         select Poly st        =  Poly.inline (lang st) (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 (lang st) (fmts st) s; return (d, st)+>         select Math st        =  do (d, sts) <- Math.display (lang st) (fmts st) (isTrue (toggles st) auto) (stacks st) (align st) s+>                                     return (d, st{stacks = sts})+>         select Poly st        =  do (d, pstack') <- Poly.display (lang st) (lineno st + 1) (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 (lang st) (fmts st) s+>                                     let p = sub'pragma $ Text ("LINE " ++ show (lineno st + 1) ++ " " ++ show (takeFileName $ file st))+>                                     return ((if pragmas st then ((p <> sub'nl) <>) else id) 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                     :: Lang -> Directive -> String +>                               -> (FilePath,LineNo) -> [CondInfo] -> Toggles+>                               -> [Numbered Class] -> Formatter+> directive lang d s (f,l) stack togs ts+>                               =  dir d s stack+>   where+>   dir If s bs                 =  do b <- fromEither (eval lang togs s)+>                                     skipOrFormat ((f, l, bool b, True) : bs) ts+>   dir Elif s ((f,l,b2,b1):bs) =  do b <- fromEither (eval lang 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                          =  all (\(_,_,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" `isPrefixOf` 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+>                                       -- hPutStrLn stderr ("sending: " ++ script)+>                                       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+>                                      -- hPutStrLn stderr ("received: " ++ l)+>                                      let n'  |  (null . snd . breaks (isPrefixOf magic)) l  =  n+>                                              |  otherwise                                   =  n - 1+>                                      fmap (l:) (readMagic n')++> extract                       :: String -> String+> extract s                     =  v+>     where (t, u)              =  breaks (isPrefixOf 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 (isPrefixOf (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-2011 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."
+ src/Math.lhs view
@@ -0,0 +1,237 @@+%-------------------------------=  --------------------------------------------+\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+> import TeXCommands ( Lang(..) )++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline                        :: Lang -> Formats -> Bool -> String -> Either Exc Doc+> inline lang fmts auto         =  fmap unNL+>                               .> tokenize lang+>                               @> 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                       :: Lang -> Formats -> Bool -> (Stack, Stack) -> Maybe Int+>                               -> String -> Either Exc (Doc, (Stack,Stack))+> display lang fmts auto sts col=  lift trim+>                               @> lift (expand 0)+>                               @> tokenize lang+>                               @> 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 False 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 False sub'space) : t : before False ts+>         Keyword _             -> fromToken (TeX False sub'space) : t : after ts+>         _                     -> fromToken (TeX False 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}+
+ src/MathCommon.lhs view
@@ -0,0 +1,224 @@+%-------------------------------=  --------------------------------------------+\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+>+> import Control.Monad++> 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)++> pos2string :: Pos a -> String+> pos2string (Pos r c _) = "'" ++ show r ++ "_" ++ show c++%}++> 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 (Pos tok) -> [Pos tok]+> substitute d auto chunk       =  snd (eval chunk)+>   where+>   eval                        :: (CToken tok) => [Item (Pos tok)] -> (Mode,[Pos tok])+>   eval [e]                    =  eval' e+>   eval chunk                  =  (Optional False, concat [ snd (eval' i) | i <- chunk ])+>+>   eval'                       :: (CToken tok) => Item (Pos tok) -> (Mode,[Pos tok])+>   eval' (Delim s)             =  (Optional False, [s])+>   eval' (Apply [])            =  impossible "eval'"+>   eval' (Apply (e : es))      =  eval'' False e es+>+>   eval''                      :: (CToken tok) => Bool -> Atom (Pos tok) -> [Atom (Pos tok)] -> (Mode,[Pos tok])+>   eval'' _ (Atom s) es        =  case FM.lookup (string (token s) ++ pos2string s) d `mplus` 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 (Pos tok)] -> [Pos tok]+>   args es                     =  concat [ sp ++ snd (eval'' False i []) | i <- es ] -- $\cong$ Applikation+>   sp                          :: (CToken tok) => [Pos tok]+>   sp | auto                   =  [fromToken (TeX False 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)
+ src/MathPoly.lhs view
@@ -0,0 +1,406 @@+%-------------------------------=  --------------------------------------------+\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 TeXCommands            (  Lang(..)  )+> -- import Debug.Trace ( trace )++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline                        :: Lang -> Formats -> Bool -> String -> Either Exc Doc+> inline lang fmts auto         =  fmap unNL+>                               .> tokenize lang+>                               @> 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                       :: Lang -> Int -> Formats -> Bool -> Int -> Int -> Stack+>                               -> String -> Either Exc (Doc, Stack)+> display lang line fmts auto sep lat stack+>                               =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize lang+>                               @> lift (number line 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 False 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 False 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)++The function |isInternal| returns |True| iff the argument is a symbol+or a special internal symbol. See @HsLexer@ for the list of special+symbols.++> 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 (any (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 False 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 False sub'space) : t : before False ts+>         Keyword _             -> fromToken (TeX False sub'space) : t : after ts+>         _                     -> fromToken (TeX False 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: I don't quite understand the meaning of |auto|. Even+if |auto = False|, the stack is still updated.++ks, 16.07.2003: I'm going to implement the following relatively simple+heuristic for indentation. Based on my current experience with the+@poly@-style I think that this is sufficient. If not, one can still+indent explicitly via annotations.++> type Stack                    =  [(Col, Line [Pos Token])]++The stack is a list of pairs of column numbers and tokens. The head+of the list is the largest column number, and the column numbers in+the list appear sorted and descending.++Indentations occur at the beginning of a line, and the position+of the first token of the line is relevant. First, the stack is+adjusted: all elements that have a higher or equal column number+than the current line are removed.++In the now topmost stack element, we then look for the final token+that occurs at a column less than or equal to the current element.+Relative to this token, we indent. Note: this happens in \emph{all}+situations, currently. Perhaps, there are a few situations where+this is not a good idea, but let's see.++As a final step, the current line is placed on the stack.++> leftIndent                    :: Formats -> Bool +>                               -> [Col]        -- centered columns+>                               -> Stack        -- current 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)  -- done+>   loop first stack (l:ls)     =  case l of+>       Blank                   -> loop True stack ls -- ignore blank lines+>    {-| Poly x || trace (show x) False -> undefined |-}+>       Poly []                 -> loop True stack ls -- next line+>       Poly (((n,c),[],ind):rs)+>         | first               -> loop True stack (Poly rs:ls) -- ignore leading blank columns+>       Poly p@(((n,c),ts,ind):rs)+>         | first               -> -- check indentation+>                                  let -- step 1: shrink stack+>                                      rstack  = dropWhile (\(rc,_) -> rc >= c) stack+>                                      -- step 2: find relevant column+>                                      (rn,rc) = findrel (n,c) rstack+>                                      -- step 3: place line on stack+>                                      fstack  = (c,l) : rstack+>                                  in mkFromTo fstack rn n rc [fromToken $ TeX False (indent (rn,rc) (n,c))] p ls+>                                              +>+>         | c `elem` z          -> mkFromTo stack n (n ++ "E") c ts rs ls+>                                                     -- treat centered lines special+>       Poly [((n,c),ts,ind)]   -> mkFromTo stack n "E" c ts [] ls+>                                                     -- last columns+>       Poly (((n,c),ts,ind):rs@(((nn,_),_,_):_))+>                               -> mkFromTo stack n nn  c ts rs ls +>+>   mkFromTo                    :: Stack -> String -> String -> Col -> [Pos Token] -> [((String, Int), [Pos Token], Bool)] -> [Line [Pos Token]] -> (Doc, Stack)+>   mkFromTo stack bn en c ts rs ls+>     | bn == en                =  -- this can happen at the beginning of a line due to indentation+>                                  (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++%+\begin{verbatim}+where |a      =    where |Str c =    [    [    (    {+      |(b, c) =          |c@(..)=    ,    |    ,    ;+                                     ]    ]    )    }+\end{verbatim}+
+ src/NewCode.lhs view
@@ -0,0 +1,104 @@+%-------------------------------=  --------------------------------------------+\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 )+> import TeXCommands            (  Lang(..) )++%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                       :: Lang -> Formats -> String -> Either Exc Doc+> display lang fmts             =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize lang+>                               @> 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 False d)       =  d+>     tex _ (TeX True d)        =  sub'tex 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) (sub'backquoted (tex Empty t'))+>         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]+
+ src/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
+ src/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
+ src/TeXCommands.lhs view
@@ -0,0 +1,104 @@+%-------------------------------=  --------------------------------------------+\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++These don't really belong into a module named TeXCommands:++> data Style                    =  Version | Help | SearchPath | Copying | Warranty | CodeOnly | NewCode | Verb | Typewriter | Poly | Math | Pre+>                                  deriving (Eq, Show, Enum, Bounded)++> data Lang                     =  Haskell | Agda+>                                  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 Lang where+>     representation            =  [ ("haskell", Haskell), ("agda", Agda) ]+> 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|).
+ src/TeXParser.lhs view
@@ -0,0 +1,244 @@+%-------------------------------=  --------------------------------------------+\subsection{Pseudo-\TeX\ Parser}+%-------------------------------=  --------------------------------------------++%if codeOnly || showModuleHeader++> module TeXParser              (  texparse  )+> where+> import Data.Char              (  isSpace, isAlpha  )+> import TeXCommands+> import Data.List              (  isPrefixOf  )+> 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          =  isPrefixOf 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+>     ([], '%' : t)             -> Many "\\%" : classify t+>     _                         -> 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' ]
+ src/Typewriter.lhs view
@@ -0,0 +1,97 @@+%-------------------------------=  --------------------------------------------+\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+> import TeXCommands ( Lang (..) )++%endif++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Inline and display code}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> inline, display               :: Lang -> Formats -> String -> Either Exc Doc+> inline lang dict              =  tokenize lang+>                               @> lift (latexs sub'thin sub'thin dict)+>                               @> lift sub'inline++> display lang dict             =  lift trim+>                               @> lift (expand 0)+>                               @> tokenize lang+>                               @> 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 False d)       =  d+>     tex _ (TeX True d)        =  sub'tex 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) (sub'backquoted (tex Empty t'))+>         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) ++ " "
+ src/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++}+%}
+ src/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+
+ src/Version.lhs.in view
@@ -0,0 +1,58 @@+%if doc+\newcommand\ProgramVersion{@VERSION@}+%else+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Program version information}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> module Version where+>+> import FileNameUtils+> import Data.List+> import System.Info+>+> version                       :: String+> version                       =  "@VERSION@"+> numversion                    :: Int+> numversion                    =  @NUMVERSION@++Used internally to distinguish prereleases.++> pre                           :: Int+> pre                           =  @PRE@++> isWindows = "win" `isPrefixOf` os || "Win" `isPrefixOf` os++% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -+\subsubsection{Search path}+% - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -++> searchPath                    =  "." :+>                                  [  deep (joinPath (env "HOME" : [p ++ x]))+>                                  |  p <- ["","."]+>                                  ,  x <- lhs2TeXNames+>                                  ] +++>                                  [deep (joinPath [env "LHS2TEX"])] +++>                                  [deep stydir] +++>                                  [  deep (path [dir])+>                                  |  dir  <-  lhs2TeXNames+>                                  ,  path <-  if isWindows then [] else+>                                              [\x -> absPath (joinPath $ ["usr","local","share"] ++ x)+>                                              ,\x -> absPath (joinPath $ ["usr","local","lib"] ++ x)+>                                              ,\x -> absPath (joinPath $ ["usr","share"] ++ x)+>                                              ,\x -> absPath (joinPath $ ["usr","lib"] ++ x)+>                                              ]+>                                  ]+>+> lhs2TeXNames                  :: [FilePath]+> lhs2TeXNames                  =  ["lhs2tex-@SHORTVERSION@"+>                                  ,"lhs2tex"+>                                  ,"lhs2TeX"+>                                  ]+>+> stydir                        =  replace (replace "@stydir@" "datarootdir" "@datarootdir@") "prefix" "@prefix@"+>   where replace x w y  |  ("$" ++ w) `isPrefixOf` x = y ++ drop (length w + 1) x+>                        |  ("${" ++ w ++ "}") `isPrefixOf` x = y ++ drop (length w + 3) x+>                        |  otherwise = x++%endif