packages feed

lhs2tex 1.13 → 1.14

raw patch · 34 files changed

+493/−215 lines, 34 filesdep +utf8-stringsetup-changed

Dependencies added: utf8-string

Files

Directives.lhs view
@@ -44,18 +44,18 @@ repr"asentiert, da math |Pos Token| verlangt.  >-> parseFormat                   :: String -> Either Exc (String, Equation)-> parseFormat s                 =  parse equation (convert s)+> parseFormat                   :: Lang -> String -> Either Exc (String, Equation)+> parseFormat lang s            =  parse lang (equation lang) (convert s)  Format directives. \NB @%format ( = "(\;"@ is legal. -> equation                      :: Parser Token (String, Equation)-> equation                      =  do (opt, (f, opts, args)) <- optParen lhs->                                     _ <- varsym "="+> 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 "="+>                                          _ <- varsym lang "=" >                                          r <- many item >                                          return (string f, (False, [], [], r)) >                               `mplus` do f <- satisfy isVarid `mplus` satisfy isConid@@ -74,7 +74,8 @@ >       | null t && not (null w) && (null v || head w == '_') >                               =  underscore f s >       | otherwise             =  [f (reverse w)->                                  , TeX (Text ((if   not (null v)+>                                  , TeX False+>                                        (Text ((if   not (null v) >                                                then "_{" ++ reverse v ++ "}"  >                                                else "" >                                               ) ++ reverse t))@@ -93,13 +94,13 @@ >     underscore f s >                               =  [f t] >                                  ++ if null u then []->                                               else [TeX (Text ("_{"))]+>                                               else [TeX False (Text ("_{"))] >                                                    ++ >                                                    proc_u >                                                    ++->                                                    [TeX (Text ("}"))]+>                                                    [TeX False (Text ("}"))] >         where (t, u)          =  break (== '_') s->               tok_u           =  tokenize (tail u)+>               tok_u           =  tokenize lang (tail u) >               proc_u          =  case tok_u of >                                    Left  _ -> [f (tail u)] -- should not happen >                                    Right t -> t@@ -133,26 +134,31 @@ > type Substs                   =  FiniteMap Char Subst > type Subst                    =  [Doc] -> Doc -> parseSubst                    :: String -> Either Exc (String, Subst)-> parseSubst s                  =  parse substitution (convert s)+> parseSubst                    :: Lang -> String -> Either Exc (String, Subst)+> parseSubst lang s             =  parse lang (substitution lang) (convert s) >-> substitution                  =  do s <- varid+> substitution lang             =  do s <- varid >                                     args <- many varid->                                     _ <- varsym "="+>                                     _ <- 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+>       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 isVarid; return (string x)+> varid                         =  do x <- satisfy (\ x -> isVarid x && x /= (Varid "=")); return (string x) > conid                         =  do x <- satisfy isConid; return (string x)-> varsym s                      =  satisfy (== (Varsym s))+> 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 (TeX _ _)               =  True > isTeX _                       =  False  % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -@@ -163,14 +169,14 @@  Auswertung Boole'scher Ausdr"ucke. -> eval                          :: Toggles -> String -> Either Exc Value-> eval togs                     =  parse (expression togs)+> eval                          :: Lang -> Toggles -> String -> Either Exc Value+> eval lang togs                =  parse lang (expression lang togs) >-> expression                    :: Toggles -> Parser Token Value-> expression togs               =  expr+> expression                    :: Lang -> Toggles -> Parser Token Value+> expression lang togs          =  expr >   where >   expr                        =  do e1 <- appl->                                     e2 <- optional (do op <- varsym'; e <- expr; return (op, e))+>                                     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@@ -199,29 +205,31 @@  Definierende Gleichungen. -> define                        :: Toggles -> String -> Either Exc (String, Value)-> define togs                   =  parse (definition togs)+> define                        :: Lang -> Toggles -> String -> Either Exc (String, Value)+> define lang togs              =  parse lang (definition lang togs) >-> definition                    :: Toggles -> Parser Token (String, Value)-> definition togs               =  do Varid x <- satisfy isVarid->                                     _ <- equal'->                                     b <- expression 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. -> equal', not',  true', false', open', close'+> not',  true', false', open', close' >                               :: Parser Token Token-> equal'                        =  satisfy (== (Varsym "="))+> 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'                       =  do x <- satisfy isVarsym; return (string x)-> isVarsym (Varsym _)           =  True-> isVarsym _                    =  False+> 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@@ -229,9 +237,10 @@  Hilfsfunktionen. -> parse                         :: Parser Token a -> [Char] -> Either Exc a-> parse p str                   =  do ts <- tokenize str->                                     let ts' = filter (\t -> catCode t /= White || isTeX t) ts+> parse                         :: Lang -> Parser Token a -> [Char] -> 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) 
Document.lhs view
@@ -57,6 +57,7 @@ > 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]
+ Examples/Fig.lhs view
@@ -0,0 +1,38 @@+\documentclass{article}++%include polycode.fmt++\newenvironment{figurehscode}+        {\(\parray}+        {\endparray\)}+\newenvironment{codefigure}+        {\begin{figure}\sethscode{figurehscode}}+        {\end{figure}}++\begin{document}++%Some text before.+\input tufte+\begin{figure}[h]+\texths++> map     ::  (a -> b) -> [a] -> [b]+> map []  =   []++\caption{Foobar}+\label{foobar}+\end{figure}+%Some text after.+\input tufte+\begin{codefigure}++> map     ::  (a -> b) -> [a] -> [b]+> map []  =   []++\caption{Foobar}+\label{foobar2}+\end{codefigure}+\input tufte+++\end{document}
+ Examples/SeqBack.lhs view
@@ -0,0 +1,12 @@+\documentclass{article}++%include polycode.fmt++%format `seq` = "\backtick{seq}"+\newcommand{\backtick}[1]{\;\mathsf{\text{\`{}}\!#1\!\text{\`{}}}\;}++\begin{document}+\begin{code}+`seq`+\end{code}+\end{document}
FileNameUtils.lhs view
@@ -7,8 +7,8 @@ >                               , module System.FilePath >                               ) where >-> import Prelude hiding         (  catch )-> import System.IO+> import Prelude hiding         (  catch, readFile )+> import System.IO.UTF8 > import System.Directory > import System.Environment > import Data.List
HsLexer.lhs view
@@ -7,10 +7,12 @@ > module HsLexer                (  module HsLexer ) --Token(..), isVarid, isConid, isNotSpace, string, tokenize  ) > where > import Data.Char 	(  isSpace, isUpper, isLower, isDigit, isAlphaNum  )+> import qualified Data.Char ( isSymbol ) > import Control.Monad > import Control.Monad.Error () > import Document > import Auxiliaries+> import TeXCommands    (  Lang(..)  )  %endif Ein Haskell-Lexer. Modifikation der Prelude-Funktion \hs{lex}.@@ -28,7 +30,7 @@ >                               |  Nested String >                               |  Pragma String >                               |  Keyword String->                               |  TeX Doc              -- for inline \TeX+>                               |  TeX Bool Doc        -- for inline \TeX (True) and format replacements (False) >                               |  Qual [String] Token >                               |  Op Token >                                  deriving (Eq, Show)@@ -63,18 +65,21 @@ > string (Nested s)             =  "{-" ++ s ++ "-}" > string (Pragma s)             =  "{-#" ++ s ++ "#-}" > string (Keyword s)            =  s-> string (TeX (Text 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 (TeX _ _)              =  "" -- |impossible "string"| > string (Qual m s)             =  concatMap (++".") m ++ string s > string (Op s)                 =  "`" ++ string s ++ "`" -> tokenize                      :: [Char] -> Either Exc [Token]-> tokenize                      =  lift tidyup @@ lift qualify @@ lexify+The main function. +> tokenize                      :: Lang -> [Char] -> Either Exc [Token]+> tokenize lang                 =  lift tidyup @@ lift qualify @@ lexify lang+ % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - \subsubsection{Phase 1} % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - -@@ -82,50 +87,57 @@ %{ %format lex' = "\Varid{lex}" -> lexify                        :: [Char] -> Either Exc [Token]-> lexify []                     =  return []-> lexify s@(_ : _)              =  case lex' s of+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 s'; return (t : ts)+>     Just (t, s')              -> do ts <- lexify lang s'; return (t : ts) >-> lex'                          :: String -> Maybe (Token, String)-> lex' ""                       =  Nothing-> lex' ('\'' : s)               =  do let (t, u) = lexLitChar s+> 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' ('"' : s)                =  do let (t, u) = lexLitStr s+> lex' lang ('"' : s)           =  do let (t, u) = lexLitStr s >                                     v <- match "\"" u >                                     return (String ("\"" ++ t ++ "\""), v)-> lex' ('-' : '-' : s)->   | not (null s') && isSymbol (head s')+> lex' lang ('-' : '-' : s)+>   | not (null s') && isSymbol lang (head s') >                               =  case s' of->                                    (c : s'') -> return (Varsym ("--" ++ d ++ [c]), s'')+>                                    (c : s'') -> return (varsymid lang ("--" ++ d ++ [c]), s'') >   | otherwise                 =  return (Comment t, u) >   where (d, s') = span (== '-') s >         (t, u)  = break (== '\n') s'-> lex' ('{' : '-' : '"' : s)    =  do let (t, u) = inlineTeX s+> lex' lang ('{' : '-' : '"' : s) +>                               =  do let (t, u) = inlineTeX s >                                     v <- match "\"-}" u->                                     return (TeX (Text t), v)-> lex' ('{' : '-' : '#' : s)    =  do let (t, u) = nested 0 s+>                                     return (TeX True (Text t), v)+> lex' lang ('{' : '-' : '#' : s)+>                               =  do let (t, u) = nested 0 s >                                     v <- match "#-}" u >                                     return (Pragma t, v)-> lex' ('{' : '-' : s)          =  do let (t, u) = nested 0 s+> lex' lang ('{' : '-' : s)     =  do let (t, u) = nested 0 s >                                     v <- match "-}" u >                                     return (Nested t, v)-> lex' (c : s)+> 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 s in return (Conid (c : t), u)->     | isLower c || c == '_'   =  let (t, u) = span isIdChar s in return (classify (c : t), u)->     | c == ':'                =  let (t, u) = span isSymbol s in return (Consym (c : t), u)->     | isSymbol c              =  let (t, u) = span isSymbol s in return (Varsym (c : t), u)+>     | 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 (c : ds ++ fe), u)+>                                     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   =  Keyword s+>         | s `elem` keywords lang+>                               =  Keyword s >         | otherwise           =  Varid   s > >@@ -149,6 +161,11 @@ > 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.@@ -189,10 +206,13 @@ > lexLitStr ('\\' : c : s)      =  '\\' <| c <| lexLitStr s > lexLitStr (c : s)             =  c <| lexLitStr s -> isSpecial, isSymbol, isIdChar :: Char -> Bool+> isSpecial                     :: Char -> Bool+> isIdChar, isSymbol            :: Lang -> Char -> Bool > isSpecial c                   =  c `elem` ",;()[]{}`"-> isSymbol c                    =  c `elem` "!@#$%&*+./<=>?\\^|:-~"-> isIdChar c                    =  isAlphaNum c || c `elem` "_'"+> isSymbol Haskell c            =  c `elem` "!@#$%&*+./<=>?\\^|:-~" || Data.Char.isSymbol 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@@ -202,21 +222,28 @@  \NB |match| entspricht eigentlich |lits|. -Schl"usselw"orter.+Keywords -> keywords                      :: [String]-> keywords                      =  [ "case",     "class",    "data",  "default",+> 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} % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - -Zusammenf"ugen von qualifizierten Namen.+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@@ -313,17 +340,23 @@ |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->     catCode (Varsym _)        =  Sep+>     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+>         | c `elem` "([{}])"   =  Del c >         | otherwise           =  Sep  \NB Only @([])@ are classified as delimiters; @{}@ are separators since@@ -333,12 +366,12 @@ >     catCode (Nested _)        =  White >     catCode (Pragma _)        =  White >     catCode (Keyword _)       =  Sep->     catCode (TeX (Text _))    =  White+>     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 (TeX _ _)         =  NoSep -- |impossible "catCode"| >     catCode (Qual _ t)        =  catCode t >     catCode (Op _)            =  Sep >     token                     =  id
INSTALL view
@@ -28,7 +28,7 @@ Unpack the archive. Assume that it has been unpacked into directory "/somewhere". Then say -cd /somewhere/lhs2TeX-1.13+cd /somewhere/lhs2TeX-1.14 ./configure make make install@@ -44,18 +44,18 @@ lhs2TeX binary. The default search path is as follows:  .-{HOME}/lhs2tex-1.13//+{HOME}/lhs2tex-1.14// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.13//+{HOME}/.lhs2tex-1.14// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.13//-/usr/local/share/lhs2tex-1.13//-/usr/local/lib/lhs2tex-1.13//-/usr/share/lhs2tex-1.13//-/usr/lib/lhs2tex-1.13//+/usr/local/share/lhs2tex-1.14//+/usr/local/share/lhs2tex-1.14//+/usr/local/lib/lhs2tex-1.14//+/usr/share/lhs2tex-1.14//+/usr/lib/lhs2tex-1.14// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
+ Library/agda.fmt view
@@ -0,0 +1,58 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% agda.fmt+%+% basic definitions for formatting agda code+%+% Permission is granted to include this file (or parts of this file) +% literally into other documents, regardless of the conditions or +% license applying to these documents.+%+% Andres Loeh, October 2008, ver 1.0+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_agda_fmt_read+%let lhs2tex_agda_fmt_read = True+%include polycode.fmt+%+%if style /= newcode+\ReadOnlyOnce{agda.fmt}%++%if lang == agda++\RequirePackage[T1]{fontenc}+\RequirePackage[utf8]{inputenc}+\RequirePackage{ucs}+\RequirePackage{amsfonts}++\providecommand\mathbbm{\mathbb}++% TODO: Define more of these ...+\DeclareUnicodeCharacter{737}{\textsuperscript{l}}+\DeclareUnicodeCharacter{8718}{\ensuremath{\blacksquare}}+\DeclareUnicodeCharacter{8759}{::}+\DeclareUnicodeCharacter{9669}{\ensuremath{\triangleleft}}+\DeclareUnicodeCharacter{8799}{\ensuremath{\stackrel{\scriptscriptstyle ?}{=}}}+\DeclareUnicodeCharacter{10214}{\ensuremath{\llbracket}}+\DeclareUnicodeCharacter{10215}{\ensuremath{\rrbracket}}++% TODO: This is in general not a good idea.+\providecommand\textepsilon{$\epsilon$}+\renewcommand\textmu{$\mu$}++%subst keyword a = "\Keyword{" a "}"++%Actually, varsyms should not occur in Agda output.+%subst varsym a = "\Varid{" a "}"++% TODO: Make this configurable. IMHO, italics doesn't work well+% for Agda code.++\renewcommand\Varid[1]{\mathord{\textsf{#1}}}+\let\Conid\Varid+\newcommand\Keyword[1]{\textsf{\textbf{#1}}}+\EndFmtInput++%endif+%endif+%endif
+ Library/exists.fmt view
@@ -0,0 +1,36 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% exists.fmt+%+% Format exists x. y as \exists x. y in TeX, not as compose+% Based on forall.fmt; look there for slightly more+% documentation.+%+% Andres Loeh, September 2008, version 1.1+% Duncan Coutts, September 2008, copy'n'pasted from lambda.fmt+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_exists_fmt_read+%let lhs2tex_exists_fmt_read = True+%include lhs2TeX.fmt+%include forall.fmt+%+%if style /= newcode+%format exists(x) = exists_ x "\hsexists "+%format exists_   = "\exists "+%+\ReadOnlyOnce{exists.fmt}%+\makeatletter++\newcommand\hsexists{\global\let\hsdot=\hsperiodonce}++\AtHaskellReset{\global\let\hsdot=\hscompose}++% In the beginning, we should reset Haskell once.+\HaskellReset++\makeatother+\EndFmtInput+%endif+%endif
+ Library/lambda.fmt view
@@ -0,0 +1,39 @@+%if False+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+% lambda.fmt+%+% Format \ x -> y as \ x . y in TeX+% Based on forall.fmt; look there for slightly more+% documentation.+%+% Andres Loeh, September 2008, version 1.1+%+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%+%endif+%if not lhs2tex_lambda_fmt_read+%let lhs2tex_lambda_fmt_read = True+%include lhs2TeX.fmt+%include forall.fmt+%+%if style /= newcode+%format \         = lambda_ "\hslambda "+%format ->        = "\hsarrow{" `arrow_` "}{" lambdaperiod_ "}"+%format `arrow_`  = "\rightarrow "+%format lambda_   = "\lambda "+%format lambdaperiod_ = "\mathpunct{.}"+%+\ReadOnlyOnce{lambda.fmt}%+\makeatletter++\newcommand\hslambda{\global\let\hsarrow=\hsarrowperiodonce}+\newcommand*\hsarrowperiodonce[2]{#2\global\let\hsarrow=\hscompose}++\AtHaskellReset{\global\let\hsarrow=\hscompose}++% In the beginning, we should reset Haskell once.+\HaskellReset++\makeatother+\EndFmtInput+%endif+%endif
Main.lhs view
@@ -9,7 +9,8 @@ > > import Data.Char ( isSpace ) > import Data.List ( isPrefixOf )-> import System.IO ( hClose, hPutStr, hPutStrLn, hFlush, hGetLine, stderr, stdout, openFile, IOMode(..), Handle(..) )+> import System.IO ( hClose, hFlush, stderr, stdout, openFile, IOMode(..), Handle(..) )+> import System.IO.UTF8 ( hPutStr, hPutStrLn, hGetLine ) > import System.Directory ( copyFile ) > import System.Console.GetOpt > import Text.Regex ( matchRegex, mkRegexWithOpts )@@ -83,6 +84,7 @@ > type CondInfo                 =  (FilePath, LineNo, Bool, Bool)  > data State                    =  State { style      :: Style,+>                                          lang       :: Lang, >                                          verbose    :: Bool, >                                          searchpath :: [FilePath], >                                          file       :: FilePath,      -- also used for `hugs'@@ -112,7 +114,8 @@ Initial state.  > state0                        :: State-> state0                        =  State { verbose    = False,+> state0                        =  State { lang       = Haskell,+>                                          verbose    = False, >                                          searchpath = searchPath, >                                          lineno     = 0, >                                          olineno    = 0,@@ -151,7 +154,9 @@ >                                  [("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 ()@@ -206,10 +211,12 @@ >   , Option ['V'] ["version"] (NoArg (return, id, [Version]))                              "show version" >   , Option []    ["tt"]      (NoArg (return, id, [Typewriter]))                           "typewriter style" >   , Option []    ["math"]    (NoArg (return, id, [Math]))                                 "math style"->   , Option []    ["poly"]    (NoArg (return, id, [Poly]))                                 "poly style"+>   , Option []    ["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 <- openFile f WriteMode >                                                       return $ s { output = h }, id, [])) "file") "specify output file"@@ -277,8 +284,9 @@ > formats (No n  (Directive d s) : ts) >     | conditional d           =  do update (\st -> st{lineno = n}) >                                     st <- fetch->                                     directive d s (file st,n) ->                                                   (conds st) (toggles st) ts+>                                     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@@ -307,7 +315,8 @@ >            | otherwise        =  s >            where (t, u)       =  breakAfter (== '\n') s -> format (Environment Haskell s)=  display s+> format (Environment Haskell_ s)+>                               =  display s > format (Environment Code s)   =  display s > format (Environment Spec s)   =  do st <- fetch >                                     when (not (style st `elem` [CodeOnly,NewCode])) $@@ -322,10 +331,10 @@ > format (Environment (Verbatim b) s) >                               =  out (Verbatim.display 120 b s) > format (Directive Format s)   =  do st <- fetch->                                     b@(n,e) <- fromEither (parseFormat s)+>                                     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 s)+>                                     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@@ -372,7 +381,7 @@ \Todo{|toggles| should be saved, as well.}  > format (Directive Let s)      =  do st <- fetch->                                     t <- fromEither (define (toggles st) s)+>                                     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  = ([], [])})@@ -443,9 +452,9 @@ >                                     d <- fromEither (select (style st) st) >                                     eject d >   where select Verb st        =  Right (Verbatim.inline False s)->         select Typewriter st  =  Typewriter.inline (fmts st) s->         select Math st        =  Math.inline (fmts st) (isTrue (toggles st) auto) s->         select Poly st        =  Poly.inline (fmts st) (isTrue (toggles st) auto) s+>         select 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? @@ -454,12 +463,12 @@ >                                     store st' >                                     eject d >   where select Verb st        =  return (Verbatim.display 120 False s, st)->         select Typewriter st  =  do d <- Typewriter.display (fmts st) s; return (d, st)->         select Math st        =  do (d, sts) <- Math.display (fmts st) (isTrue (toggles st) auto) (stacks st) (align st) s+>         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 (fmts st) (isTrue (toggles st) auto) (separation st) (latency st) (pstack st) s+>         select Poly st        =  do (d, pstack') <- Poly.display (lang st) (fmts st) (isTrue (toggles st) auto) (separation st) (latency st) (pstack st) s >                                     return (d, st{pstack = pstack'})->         select NewCode st     =  do d <- NewCode.display (fmts st) s+>         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)@@ -491,15 +500,15 @@ ks, 16.08.2004: At the end of the input, we might want to check for unbalanced if's or groups. -> directive                     :: Directive -> String +> directive                     :: Lang -> Directive -> String  >                               -> (FilePath,LineNo) -> [CondInfo] -> Toggles >                               -> [Numbered Class] -> Formatter-> directive d s (f,l) stack togs ts+> directive lang d s (f,l) stack togs ts >                               =  dir d s stack >   where->   dir If s bs                 =  do b <- fromEither (eval togs s)+>   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 togs s)+>   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
Makefile view
@@ -182,8 +182,8 @@ 	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples 	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples 	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library-	tar cvjf $(DISTDIR).tar.bz2 $(DISTDIR)-	chmod 644 $(DISTDIR).tar.bz2+	tar cvzf $(DISTDIR).tar.gz $(DISTDIR)+	chmod 644 $(DISTDIR).tar.gz  ifdef DISTTYPE 
Math.lhs view
@@ -21,6 +21,7 @@ > import Parser > import qualified FiniteMap as FM > import Auxiliaries+> import TeXCommands ( Lang(..) )  %endif @@ -28,9 +29,9 @@ \subsubsection{Inline and display code} % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - -> inline                        :: Formats -> Bool -> String -> Either Exc Doc-> inline fmts auto              =  fmap unNL->                               .> tokenize+> 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))@@ -42,11 +43,11 @@ >                               @> lift (latexs fmts) >                               @> lift sub'inline -> display                       :: Formats -> Bool -> (Stack, Stack) -> Maybe Int+> display                       :: Lang -> Formats -> Bool -> (Stack, Stack) -> Maybe Int >                               -> String -> Either Exc (Doc, (Stack,Stack))-> display fmts auto sts col     =  lift trim+> display lang fmts auto sts col=  lift trim >                               @> lift (expand 0)->                               @> tokenize+>                               @> tokenize lang >                               @> lift (number 1 1) >                               @> when auto (lift (filter (isNotSpace . token))) >                               @> lift (partition (\t -> catCode t /= White))@@ -153,16 +154,16 @@ >         u | selfSpacing u     -> t : before False ts >         Special c >           | c `elem` ",;([{"  -> t : before False ts->         Keyword _             -> [ fromToken (TeX sub'space) | b ] ++ t : after 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 sub'space) : t : before False ts->         Keyword _             -> fromToken (TeX sub'space) : t : after ts->         _                     -> fromToken (TeX sub'space) : t : before True ts+>           | 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'. 
MathCommon.lhs view
@@ -168,7 +168,7 @@ >   args                        :: (CToken tok) => [Atom tok] -> [tok] >   args es                     =  concat [ sp ++ snd (eval'' False i []) | i <- es ] -- $\cong$ Applikation >   sp                          :: (CToken tok) => [tok]->   sp | auto                   =  [fromToken (TeX sub'space)]+>   sp | auto                   =  [fromToken (TeX False sub'space)] >      | otherwise              =  []  To support macros of the form @%format Parser (a) = a@.
MathPoly.lhs view
@@ -27,6 +27,7 @@ > import Parser > import qualified FiniteMap as FM > import Auxiliaries+> import TeXCommands            (  Lang(..)  ) > -- import Debug.Trace ( trace )  %endif@@ -35,9 +36,9 @@ \subsubsection{Inline and display code} % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - -> inline                        :: Formats -> Bool -> String -> Either Exc Doc-> inline fmts auto              =  fmap unNL->                               .> tokenize+> 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))@@ -49,12 +50,12 @@ >                               @> lift (latexs fmts) >                               @> lift sub'inline -> display                       :: Formats -> Bool -> Int -> Int -> Stack+> display                       :: Lang -> Formats -> Bool -> Int -> Int -> Stack >                               -> String -> Either Exc (Doc, Stack)-> display fmts auto sep lat stack+> display lang fmts auto sep lat stack >                               =  lift trim >                               @> lift (expand 0)->                               @> tokenize+>                               @> tokenize lang >                               @> lift (number 1 1) >       --                     |@> when auto (lift (filter (isNotSpace . token)))| >                               @> lift (partition (\t -> catCode t /= White))@@ -112,7 +113,7 @@ >                                          r <- right l >                                          return (Paren l e r) >                               `mplus` if d == 0 then do r <- anyright->                                                         return (Paren (fromToken $ TeX Empty) [] r)+>                                                         return (Paren (fromToken $ TeX False Empty) [] r) >                                                 else mzero  ks, 09.09.2003: Added handling of unbalanced parentheses, surely not in the@@ -126,13 +127,13 @@ > 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)+> 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 "([" ")]" +>                                       (Del o, Del c) -> (o,c) `elem` zip "([{" ")]}"  >                                       _     -> False) >                                  ) `mplus` do eof->                                               return (fromToken $ TeX Empty)+>                                               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@@ -271,7 +272,7 @@ >           | selfSpacing u     -> t : before False ts >         Special c >           | c `elem` ",;([{"  -> t : before False ts->         Keyword _             -> [ fromToken (TeX sub'space) | b ] ++ t : after ts+>         Keyword _             -> [ fromToken (TeX False sub'space) | b ] ++ t : after ts >         _                     -> t : before True ts >  >     after []                  =  []@@ -279,9 +280,9 @@ >         u | not (isNotSpace u)-> t : after ts >           | selfSpacing u     -> t : before False ts >         Special c->           | c `elem` ",;([{"  -> fromToken (TeX sub'space) : t : before False ts->         Keyword _             -> fromToken (TeX sub'space) : t : after ts->         _                     -> fromToken (TeX sub'space) : t : before True ts+>           | 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'. @@ -356,7 +357,7 @@ >                                      (rn,rc) = findrel (n,c) rstack >                                      -- Schritt 3: Zeile auf Stack legen >                                      fstack  = (c,l) : rstack->                                  in mkFromTo fstack rn n rc [fromToken $ TeX (indent (rn,rc) (n,c))] p ls+>                                  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
NewCode.lhs view
@@ -22,6 +22,7 @@ > import qualified FiniteMap as FM > import Auxiliaries > import MathPoly               (  exprParse, substitute, number )+> import TeXCommands            (  Lang(..) )  %endif @@ -32,10 +33,10 @@ \NB We do not need an |inline| function because we are only interested in the ``real'' program code. All comments are deleted. -> display                       :: Formats -> String -> Either Exc Doc-> display fmts                  =  lift trim+> display                       :: Lang -> Formats -> String -> Either Exc Doc+> display lang fmts             =  lift trim >                               @> lift (expand 0)->                               @> tokenize+>                               @> tokenize lang >                               @> lift (number 1 1) >                               @> lift (partition (\t -> catCode t /= White)) >                               @> exprParse *** return@@ -77,7 +78,8 @@ >     tex _ (Nested s)          =  sub'nested (convert s) >     tex _ (Pragma s)          =  sub'pragma (convert s) >     tex _ (Keyword s)         =  replace Empty s (sub'keyword (convert s))->     tex _ (TeX d)             =  d+>     tex _ (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
RELEASE view
@@ -1,5 +1,5 @@ -                     lhs2TeX version 1.13+                     lhs2TeX version 1.14                      ====================  We are pleased to announce a new release of lhs2TeX, @@ -20,34 +20,33 @@  * A manual explaining all the important aspects of lhs2TeX. -Changes (w.r.t. lhs2TeX 1.12)+Changes (w.r.t. lhs2TeX 1.13) ----------------------------- -* Compatible with ghc-6.8.{1,2}.--* Compatible with cabal-1.2; traditional configure/make+* Compatible with cabal-1.6; traditional configure/make   installation should still work. -* Uses filepath.--* LINE pragmas can be disabled with --no-pragmas.+* Unicode support. -* Fixed comment lexing bugs (--> was considered a Haskell comment,-  \% was considered a TeX comment)+* Support for Agda's lexing rules (via --agda flag). -* Added a %subst directive for backquoted operators.+* Minor bugfixes.  Requirements and Download -------------------------  A source distribution is available from -  http://www.cs.uu.nl/~andres/lhs2tex/+  http://people.cs.uu.nl/andres/lhs2tex/ +and, of course, via Hackage:++  http://hackage.haskell.org/cgi-bin/hackage-scripts/package/lhs2tex+ Should work on all major platforms, but has mainly been tested on Linux. Binaries will be made available on request. -You need a recent version of GHC (6.8.2 is tested, older versions+You need a recent version of GHC (6.8.{2,3} are tested, older versions might work) to build lhs2TeX, and, of course, you need a TeX distribution to make use of lhs2TeX's output. The program includes a configuration that is suitable for use with LaTeX. In theory, 
Setup.hs view
@@ -1,12 +1,12 @@ import Distribution.Simple.Setup (CopyDest(..),ConfigFlags(..),BuildFlags(..),                                   CopyFlags(..),RegisterFlags(..),InstallFlags(..),-                                  emptyRegisterFlags)+                                  defaultRegisterFlags,fromFlagOrDefault,Flag(..),+                                  defaultCopyFlags) import Distribution.Simple-import Distribution.Simple.Utils (die,rawSystemExit,maybeExit,copyFileVerbose) import Distribution.Simple.LocalBuildInfo-                            (LocalBuildInfo(..),mkDataDir,absoluteInstallDirs)+                            (LocalBuildInfo(..),absoluteInstallDirs) import Distribution.Simple.Configure (configCompilerAux)-import Distribution.PackageDescription (PackageDescription(..),setupMessage)+import Distribution.PackageDescription (PackageDescription(..)) import Distribution.Simple.InstallDirs                             (InstallDirs(..)) import Distribution.Simple.Program @@ -18,6 +18,7 @@ import Data.Char (isSpace, showLitChar) import Data.List (isSuffixOf,isPrefixOf) import Data.Maybe (listToMaybe,isJust)+import Data.Version import Control.Monad (when,unless) import Text.Regex (matchRegex,matchRegexAll,mkRegex,mkRegexWithOpts,subRegex) import Text.ParserCombinators.ReadP (readP_to_S)@@ -33,9 +34,9 @@ minPolytableVersion = [0,8,2] shortversion = show (numversion `div` 100) ++ "." ++ show (numversion `mod` 100) version = shortversion ++ if ispre then "pre" ++ show pre else ""-numversion = 113+numversion = 114 ispre = False-pre = 4+pre = 2  main = defaultMainWithHooks lhs2texHooks @@ -53,7 +54,7 @@                      rebuildDocumentation  ::  Bool }   deriving (Show, Read) -lhs2texHooks = defaultUserHooks+lhs2texHooks = simpleUserHooks                  { hookedPrograms = [simpleProgram "hugs",                                      simpleProgram "kpsewhich",                                      simpleProgram "pdflatex",@@ -67,7 +68,7 @@                  }  lhs2texPostConf a cf pd lbi =-    do  let v = configVerbose cf+    do  let v = fromFlagOrDefault normal (configVerbosity cf)         -- check polytable         (_,b,_) <- runKpseWhichVar "TEXMFLOCAL"         b       <- return . stripQuotes . stripNewlines $ b@@ -128,8 +129,9 @@   where runKpseWhich v = runCommandProgramConf silent "kpsewhich" (withPrograms lbi) [v]         runKpseWhichVar v = runKpseWhich $ "-expand-var='$" ++ v ++ "'" -lhs2texPostBuild a bf@(BuildFlags { buildVerbose = v }) pd lbi =-    do  ebi <- getPersistLhs2texBuildConfig+lhs2texPostBuild a bf@(BuildFlags { buildVerbosity = vf }) pd lbi =+    do  let v = fromFlagOrDefault normal vf+        ebi <- getPersistLhs2texBuildConfig         let lhs2texDir = buildDir lbi `joinFileName` lhs2tex         let lhs2texBin = lhs2texDir `joinFileName` lhs2tex         let lhs2texDocDir = lhs2texDir `joinFileName` "doc"@@ -139,8 +141,9 @@         if rebuildDocumentation ebi then lhs2texBuildDocumentation a bf pd lbi                                     else copyFileVerbose v ("doc" `joinFileName` "Guide2.pdf") (lhs2texDocDir `joinFileName` "Guide2.pdf") -lhs2texBuildDocumentation a (BuildFlags { buildVerbose = v }) pd lbi =-    do  let lhs2texDir = buildDir lbi `joinFileName` lhs2tex+lhs2texBuildDocumentation a (BuildFlags { buildVerbosity = vf }) pd lbi =+    do  let v = fromFlagOrDefault normal vf+        let lhs2texDir = buildDir lbi `joinFileName` lhs2tex         let lhs2texBin = lhs2texDir `joinFileName` lhs2tex         let lhs2texDocDir = lhs2texDir `joinFileName` "doc"         snippets <- do  guide <- readFile $ "doc" `joinFileName` "Guide2.lhs"@@ -180,8 +183,10 @@         loop         setCurrentDirectory d -lhs2texPostCopy a (CopyFlags { copyDest = cd, copyVerbose = v }) pd lbi =-    do  ebi <- getPersistLhs2texBuildConfig+lhs2texPostCopy a (CopyFlags { copyDest = cdf, copyVerbosity = vf }) pd lbi =+    do  let v = fromFlagOrDefault normal vf+        let cd = fromFlagOrDefault NoCopyDest cdf+        ebi <- getPersistLhs2texBuildConfig         let dataPref = datadir (absoluteInstallDirs pd lbi cd)         createDirectoryIfMissing True dataPref         let lhs2texDir = buildDir lbi `joinFileName` lhs2tex@@ -218,18 +223,19 @@                                   stys           Nothing    -> return () -lhs2texPostInst a (InstallFlags { installPackageDB = db, installVerbose = v }) pd lbi =-    do  lhs2texPostCopy a (CopyFlags { copyDest = NoCopyDest, copyVerbose = v }) pd lbi-        lhs2texRegHook pd lbi Nothing (emptyRegisterFlags { regPackageDB = db, regVerbose = v })+lhs2texPostInst a (InstallFlags { installPackageDB = db, installVerbosity = v }) pd lbi =+    do  lhs2texPostCopy a (defaultCopyFlags { copyDest = Flag NoCopyDest, copyVerbosity = v }) pd lbi+        lhs2texRegHook pd lbi Nothing (defaultRegisterFlags { regPackageDB = db, regVerbosity = v }) -lhs2texRegHook pd lbi _ (RegisterFlags { regVerbose = v }) =-    do  ebi <- getPersistLhs2texBuildConfig+lhs2texRegHook pd lbi _ (RegisterFlags { regVerbosity = vf }) =+    do  let v = fromFlagOrDefault normal vf+        ebi <- getPersistLhs2texBuildConfig         when (isJust . installPolyTable $ ebi) $           do  rawSystemProgramConf v (simpleProgram "mktexlsr") (withPrograms lbi) []               return ()  lhs2texCleanHook pd lbi v pshs =-    do  cleanHook defaultUserHooks pd lbi v pshs+    do  cleanHook simpleUserHooks pd lbi v pshs         try $ removeFile lhs2texBuildInfoFile         mapM_ (try . removeFile) generatedFiles 
TeXCommands.lhs view
@@ -14,9 +14,14 @@  %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@@ -31,10 +36,10 @@ > data Command                  =  Hs | Eval | Perform | Vrb Bool >                                  deriving (Eq, Show) >-> data Environment              =  Haskell | Code | Spec | Evaluate | Hide | Ignore | Verbatim Bool+> data Environment              =  Haskell_ | Code | Spec | Evaluate | Hide | Ignore | Verbatim Bool >                                  deriving (Eq, Show) -\NB |Hs|, |Haskell|, |Hide|, and |Ignore| are obsolete.+\NB |Hs|, |Haskell_|, |Hide|, and |Ignore| are obsolete. ks, 16.08.2004: added EOF.  >@@ -68,12 +73,14 @@ >                                    ("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),+>     representation            =  [ ("haskell", Haskell_), ("code", Code), >                                    ("spec", Spec), ("evaluate", Evaluate), ("hide", Hide), >                                    ("ignore", Ignore), ("verbatim*", Verbatim True), >                                    ("verbatim", Verbatim False) ]
Testsuite/Makefile view
@@ -182,8 +182,8 @@ 	$(INSTALL) -m 644 Examples/*.lhs $(DISTDIR)/Examples 	$(INSTALL) -m 755 Examples/lhs2TeXpre $(DISTDIR)/Examples 	$(INSTALL) -m 644 Library/*.fmt $(DISTDIR)/Library-	tar cvjf $(DISTDIR).tar.bz2 $(DISTDIR)-	chmod 644 $(DISTDIR).tar.bz2+	tar cvzf $(DISTDIR).tar.gz $(DISTDIR)+	chmod 644 $(DISTDIR).tar.gz  ifdef DISTTYPE 
Typewriter.lhs view
@@ -13,6 +13,7 @@ > import HsLexer > import qualified FiniteMap as FM > import Auxiliaries+> import TeXCommands ( Lang (..) )  %endif @@ -20,14 +21,14 @@ \subsubsection{Inline and display code} % - - - - - - - - - - - - - - - = - - - - - - - - - - - - - - - - - - - - - - - -> inline, display               :: Formats -> String -> Either Exc Doc-> inline dict                   =  tokenize+> inline, display               :: Lang -> Formats -> String -> Either Exc Doc+> inline lang dict              =  tokenize lang >                               @> lift (latexs sub'thin sub'thin dict) >                               @> lift sub'inline -> display dict                  =  lift trim+> display lang dict             =  lift trim >                               @> lift (expand 0)->                               @> tokenize+>                               @> tokenize lang >                               @> lift (latexs sub'space sub'nl dict) >                               @> lift sub'code @@ -55,7 +56,8 @@ >     tex _ (Nested s)          =  sub'nested (Embedded s) >     tex _ (Pragma s)          =  sub'pragma (Embedded s) >     tex _ (Keyword s)         =  replace Empty s (sub'keyword (convert s))->     tex _ (TeX d)             =  d+>     tex _ (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
configure view
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.61 for lhs2tex 1.13.+# Generated by GNU Autoconf 2.61 for lhs2tex 1.14. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.@@ -572,8 +572,8 @@ # Identity of this package. PACKAGE_NAME='lhs2tex' PACKAGE_TARNAME='lhs2tex'-PACKAGE_VERSION='1.13'-PACKAGE_STRING='lhs2tex 1.13'+PACKAGE_VERSION='1.14'+PACKAGE_STRING='lhs2tex 1.14' PACKAGE_BUGREPORT=''  ac_subst_vars='SHELL@@ -1153,7 +1153,7 @@   # 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.13 to adapt to many kinds of systems.+\`configure' configures lhs2tex 1.14 to adapt to many kinds of systems.  Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1214,7 +1214,7 @@  if test -n "$ac_init_help"; then   case $ac_init_help in-     short | recursive ) echo "Configuration of lhs2tex 1.13:";;+     short | recursive ) echo "Configuration of lhs2tex 1.14:";;    esac   cat <<\_ACEOF @@ -1288,7 +1288,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then   cat <<\_ACEOF-lhs2tex configure 1.13+lhs2tex configure 1.14 generated by GNU Autoconf 2.61  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,@@ -1302,7 +1302,7 @@ 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.13, which was+It was created by lhs2tex $as_me 1.14, which was generated by GNU Autoconf 2.61.  Invocation command line was    $ $0 $@@@ -1656,10 +1656,10 @@   -VERSION="1.13"-SHORTVERSION="1.13"-NUMVERSION=113-PRE=4+VERSION="1.14"+SHORTVERSION="1.14"+NUMVERSION=114+PRE=1   @@ -3164,7 +3164,7 @@ # 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.13, which was+This file was extended by lhs2tex $as_me 1.14, which was generated by GNU Autoconf 2.61.  Invocation command line was    CONFIG_FILES    = $CONFIG_FILES@@ -3207,7 +3207,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\-lhs2tex config.status 1.13+lhs2tex config.status 1.14 configured by $0, generated by GNU Autoconf 2.61,   with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" 
doc/Guide2.lhs view
@@ -249,9 +249,9 @@   \smaller (for version \ProgramVersion)} \author{{Ralf Hinze}\\   \smaller \tabular{c}-           Institut f\"ur Informatik III, Universit\"at Bonn\\-           R\"omerstra\ss e 164, 53117 Bonn, Germany\\-           \verb|ralf@informatik.uni-bonn.de|+           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}\\@@ -398,7 +398,10 @@       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.)+      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@@ -764,7 +767,8 @@ 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+\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@@ -880,7 +884,7 @@ \begin{colorsurround} \input{Card} \end{colorsurround}-If the function is used with two few arguments as in the text,+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}). @@ -1596,6 +1600,7 @@ @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 \\
doc/Guide2.pdf view

binary file changed (319485 → 304951 bytes)

doc/RawSearchPath.lhs view
@@ -1,17 +1,17 @@ \begin{code} .-{HOME}/lhs2tex-1.13//+{HOME}/lhs2tex-1.14// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.13//+{HOME}/.lhs2tex-1.14// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.13//-/usr/local/share/lhs2tex-1.13//-/usr/local/lib/lhs2tex-1.13//-/usr/share/lhs2tex-1.13//-/usr/lib/lhs2tex-1.13//+/usr/local/share/lhs2tex-1.14//+/usr/local/share/lhs2tex-1.14//+/usr/local/lib/lhs2tex-1.14//+/usr/share/lhs2tex-1.14//+/usr/lib/lhs2tex-1.14// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
doc/poly.fmt view
@@ -6,6 +6,7 @@ %subst thinspace = "\Sp " %subst code a    = "\begin{tabbing}\texfamily'n" a "'n\end{tabbing}'n" %subst comment a = "{\rmfamily-{}- " a "}"+%subst tex a     = a %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}" %subst spaces a  = a@@ -155,6 +156,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -211,6 +213,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
doc/polytt.fmt view
@@ -8,6 +8,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -155,6 +156,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -210,6 +212,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= a %subst keyword a 	= "{\mathbf " a "}"
doc/stupid.fmt view
@@ -8,6 +8,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -155,6 +156,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -210,6 +212,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
doc/tex.fmt view
@@ -8,6 +8,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -155,6 +156,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -210,6 +212,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
doc/typewriter.fmt view
@@ -8,6 +8,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -158,6 +159,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -213,6 +215,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
doc/verbatim.fmt view
@@ -8,6 +8,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -155,6 +156,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -210,6 +212,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
lhs2TeX.fmt.lit view
@@ -39,6 +39,7 @@ %subst comment a = "{\rmfamily-{}- " a "}" %subst nested a  = "{\rmfamily\enskip\{- " a " -\}\enskip}" %subst pragma a  = "{\rmfamily\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a     = a %subst spaces a  = a %subst special a = a %subst space     = "~"@@ -213,6 +214,7 @@ %subst newline          = "'n" %subst dummy            = %subst pragma a         = "{-# " a " #-}"+%subst tex a            = %subst numeral a        = a %subst keyword a        = a %subst spaces a         = a@@ -251,7 +253,7 @@ %subst column1 a	= "${" a "}$" %endif %subst newline   	= "\\'n"-%subst blankline 	= "\\[1mm]%'n"+%subst blankline 	= "\\[0.66084ex]%'n" %let anyMath            = True %elif style == poly %subst comment a	= "\mbox{\onelinecomment " a "}"@@ -277,6 +279,7 @@ %subst inline a  	= "\ensuremath{" a "}" %subst hskip a	        = "\hskip" a "em\relax" %subst pragma a         = "\mbox{\enskip\{-\#" a " \#-\}\enskip}"+%subst tex a            = a %if latex209 %subst numeral a 	= "{\mathrm " a "}" %subst keyword a 	= "{\mathbf " a "}"
lhs2TeX.sty.lit view
@@ -173,7 +173,7 @@ \visiblecomments  \newlength{\blanklineskip}-\setlength{\blanklineskip}{1mm}+\setlength{\blanklineskip}{0.66084ex}  \newcommand{\hsindent}[1]{\quad}% default is fixed indentation \let\hspre\empty
lhs2tex.cabal view
@@ -1,13 +1,12 @@-cabal-version:  >=1.2+cabal-version:  >=1.6 name:		lhs2tex-version:	1.13+version:	1.14 license:	GPL license-file:	LICENSE author:		Ralf Hinze <ralf@informatik.uni-bonn.de>, Andres Loeh <lhs2tex@andres-loeh.de> maintainer:	Andres Loeh <lhs2tex@andres-loeh.de> stability:	stable homepage:	http://www.andres-loeh.de/lhs2tex/-package-url:	http://www.andres-loeh.de/lhs2tex/lhs2tex-1.11.tar.gz synopsis:	Preprocessor for typesetting Haskell sources with LaTeX description:	Preprocessor for typesetting Haskell sources with LaTeX category:       Development, Language@@ -19,7 +18,7 @@ executable lhs2TeX   main-is:	Main.lhs   if flag(splitBase)-    build-depends:	base >= 3, regex-compat, mtl, filepath, directory, process+    build-depends:	base >= 3, regex-compat, mtl, filepath, directory, process, utf8-string   else-    build-depends:	base < 3, regex-compat, mtl, filepath+    build-depends:	base < 3, regex-compat, mtl, filepath, utf8-string