packages feed

lhs2tex 1.22 → 1.23

raw patch · 20 files changed

+1178/−60 lines, 20 filessetup-changed

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+# lhs2tex-1.23 (2020-02-25)++- Compatibility with ghc-8.8 and Cabal-3.0 (#76).+- Lexing of hexadecimal and octal literals (#74).+ # lhs2tex-1.22 (2018-09-23)  - Compatibility with ghc-8.6.
INSTALL view
@@ -32,7 +32,7 @@ Unpack the archive. Assume that it has been unpacked into directory "/somewhere". Then say -cd /somewhere/lhs2TeX-1.22+cd /somewhere/lhs2TeX-@ProgramVersion@ ./configure make make install@@ -48,18 +48,18 @@ lhs2TeX binary. The default search path is as follows:  .-{HOME}/lhs2tex-1.22//+{HOME}/lhs2tex-1.23// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.22//+{HOME}/.lhs2tex-1.23// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.22//-/usr/local/share/lhs2tex-1.22//-/usr/local/lib/lhs2tex-1.22//-/usr/share/lhs2tex-1.22//-/usr/lib/lhs2tex-1.22//+/usr/local/share/lhs2tex-1.23//+/usr/local/share/lhs2tex-1.23//+/usr/local/lib/lhs2tex-1.23//+/usr/share/lhs2tex-1.23//+/usr/lib/lhs2tex-1.23// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 1997-2017 Ralf Hinze, Andres Loeh+Copyright (c) 1997-2020 Ralf Hinze, Andres Loeh  This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
Setup.hs view
@@ -1,4 +1,10 @@+{-# LANGUAGE CPP #-} {-# LANGUAGE PackageImports #-}++#if !defined(MIN_VERSION_Cabal)+# define MIN_VERSION_Cabal(x,y,z) 0+#endif+ import Distribution.Simple.Setup (CopyDest(..),ConfigFlags(..),BuildFlags(..),                                   CopyFlags(..),RegisterFlags(..),InstallFlags(..),                                   defaultRegisterFlags,fromFlagOrDefault,Flag(..),@@ -6,14 +12,14 @@ import Distribution.Simple  (UserHooks(..), simpleUserHooks, defaultMainWithHooks) import Distribution.Simple.LocalBuildInfo                             (LocalBuildInfo(..),absoluteInstallDirs)-import Distribution.Simple.Configure (configCompilerAux) import Distribution.PackageDescription (PackageDescription(..)) import Distribution.Simple.InstallDirs                             (InstallDirs(..)) import Distribution.Simple.Program-                            (Program(..),ConfiguredProgram(..),ProgramConfiguration(..),+                            (Program(..),ConfiguredProgram(..),                              ProgramLocation(..),simpleProgram,lookupProgram,-                             rawSystemProgramConf)+                             runDbProgram)+import Distribution.Simple.Program.Db (ProgramDb) import Distribution.Simple.Utils import Distribution.Verbosity import Data.Char (isSpace, showLitChar)@@ -181,7 +187,7 @@         d <- getCurrentDirectory         setCurrentDirectory lhs2texDocDir         -- call pdflatex as long as necessary-        let loop = do rawSystemProgramConf v (simpleProgram "pdflatex") (withPrograms lbi) ["Guide2.tex"]+        let loop = do runDbProgram v (simpleProgram "pdflatex") (withPrograms lbi) ["Guide2.tex"]                       x <- readFile "Guide2.log"                       case matchRegex (mkRegexWithOpts "Warning.*Rerun" True True) x of                         Just _  -> loop@@ -237,7 +243,7 @@     do  let v = fromFlagOrDefault normal vf         ebi <- getPersistLhs2texBuildConfig         when (isJust . installPolyTable $ ebi) $-          do  rawSystemProgramConf v (simpleProgram "mktexlsr") (withPrograms lbi) []+          do  runDbProgram v (simpleProgram "mktexlsr") (withPrograms lbi) []               return ()  lhs2texCleanHook pd lbi v pshs =@@ -285,14 +291,14 @@  runCommandProgramConf  ::  Verbosity              -- ^ verbosity                        ->  String                 -- ^ program name-                       ->  ProgramConfiguration   -- ^ lookup up the program here+                       ->  ProgramDb              -- ^ lookup up the program here                        ->  [String]               -- ^ args                        ->  IO (ExitCode,String,String) runCommandProgramConf v progName programConf extraArgs =     do  (prog,args) <- getProgram progName programConf         runCommand v prog (args ++ extraArgs) -getProgram :: String -> ProgramConfiguration -> IO (String, [String])+getProgram :: String -> ProgramDb -> IO (String, [String]) getProgram progName programConf =              do  let mProg = lookupProgram (simpleProgram progName) programConf                  case mProg of@@ -300,7 +306,7 @@                                              programDefaultArgs = args })  -> return (p,args)                    Just (ConfiguredProgram { programLocation = FoundOnSystem p,                                              programDefaultArgs = args })  -> return (p,args)-                   _ -> (die (progName ++ " command not found"))+                   _ -> (die' silent (progName ++ " command not found"))  -- | Run a command in a specific environment and return the output and errors. runCommandInEnv  ::  Verbosity             -- ^ verbosity@@ -336,11 +342,11 @@ getPersistLhs2texBuildConfig = do   e <- doesFileExist lhs2texBuildInfoFile   let dieMsg = "error reading " ++ lhs2texBuildInfoFile ++ "; run \"setup configure\" command?\n"-  when (not e) (die dieMsg)+  when (not e) (die' silent dieMsg)   str <- readFile lhs2texBuildInfoFile   case reads str of     [(bi,_)] -> return bi-    _        -> die dieMsg+    _        -> die' silent dieMsg  writePersistLhs2texBuildConfig :: Lhs2texBuildInfo -> IO () writePersistLhs2texBuildConfig lbi = do@@ -370,3 +376,8 @@  -- It would be nice if there'd be a predefined way to detect this isWindows = "mingw" `isPrefixOf` os || "win" `isPrefixOf` os++#if !(MIN_VERSION_Cabal(2,0,0))+die' :: Verbosity -> String -> IO a+die' _ = die+#endif
configure view
@@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles.-# Generated by GNU Autoconf 2.69 for lhs2tex 1.22.+# Generated by GNU Autoconf 2.69 for lhs2tex 1.23. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.@@ -576,8 +576,8 @@ # Identity of this package. PACKAGE_NAME='lhs2tex' PACKAGE_TARNAME='lhs2tex'-PACKAGE_VERSION='1.22'-PACKAGE_STRING='lhs2tex 1.22'+PACKAGE_VERSION='1.23'+PACKAGE_STRING='lhs2tex 1.23' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -1215,7 +1215,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.22 to adapt to many kinds of systems.+\`configure' configures lhs2tex 1.23 to adapt to many kinds of systems.  Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1277,7 +1277,7 @@  if test -n "$ac_init_help"; then   case $ac_init_help in-     short | recursive ) echo "Configuration of lhs2tex 1.22:";;+     short | recursive ) echo "Configuration of lhs2tex 1.23:";;    esac   cat <<\_ACEOF @@ -1355,7 +1355,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then   cat <<\_ACEOF-lhs2tex configure 1.22+lhs2tex configure 1.23 generated by GNU Autoconf 2.69  Copyright (C) 2012 Free Software Foundation, Inc.@@ -1372,7 +1372,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.22, which was+It was created by lhs2tex $as_me 1.23, which was generated by GNU Autoconf 2.69.  Invocation command line was    $ $0 $@@@ -1721,9 +1721,9 @@   -VERSION="1.22"-SHORTVERSION="1.22"-NUMVERSION=122+VERSION="1.23"+SHORTVERSION="1.23"+NUMVERSION=123 PRE=1  @@ -3400,7 +3400,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.22, which was+This file was extended by lhs2tex $as_me 1.23, which was generated by GNU Autoconf 2.69.  Invocation command line was    CONFIG_FILES    = $CONFIG_FILES@@ -3453,7 +3453,7 @@ 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.22+lhs2tex config.status 1.23 configured by $0, generated by GNU Autoconf 2.69,   with options \\"\$ac_cs_config\\" 
+ doc/Complex.lhs view
@@ -0,0 +1,36 @@+%include poly.fmt+%subst code a = "\begin{colorcode}'n" a "\end{colorcode}\resethooks'n" ++%{+%format rho = "\rho"+%format pi  = "\pi"+%format tau = "\tau"+%format sigma = "\sigma"+%format tau1+%format tau2+%format tau1'+%format tau2'+%format .==. = "\mathrel{\mathopen{.}\equiv\mathclose{.}}"+%format .->. = "\mathrel{\mathopen{.}\rightarrow\mathclose{.}}"+%format :->: = "\mathrel{\mathopen{:}\rightarrow\mathclose{:}}"++\begin{code}+functionMatch :: IsRho rho => rho -> Solve (Sigma, Rho)+functionMatch rho =+   case toRho rho of+      Exists [] (Pi tau) ->+         do  tau1   <-  newTau+             tau2   <-  newTau+             tau .==. (tau1 .->. tau2)+             tau1'  <-  subst tau1+             tau2'  <-  subst tau2+             return (toSigma tau1', toRho tau2')+      Exists [] (sigma :->: rho) ->+         do  return (sigma, rho)+      Exists is pi ->+         do  addError+               $ "*** Existential in functionMatch: " ++ show (toRho rho)+             functionMatch (toRho pi)+\end{code}++%}
+ doc/Directives.lhs view
@@ -0,0 +1,16 @@+%include tex.fmt++\begin{code}+dir(include)+dir(format)+dir({)+dir(})+dir(^let^)+dir(^if^)+dir(^else^)+dir(elif)+dir(endif)+dir(latency)+dir(separation)+dir(options)+\end{code}
− doc/Guide2.dontbuild
doc/Guide2.lhs view
@@ -14,6 +14,7 @@ \usepackage{hyperref}  %\usepackage[T1]{fontenc}+\usepackage{lmodern} \usepackage{mathpazo} %\usepackage[scaled=0.9]{luximono} \usepackage{colortbl}@@ -489,7 +490,7 @@ \paragraph{\bfseries 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+cases is classified as \textbf{plain text} and will simply pass straight through |lhs2TeX|.  @@ -498,7 +499,7 @@ \label{sec:styles} %--------------------------------------------------------------------------- -In this section, we will walk though an example to illustrate how to+In this section, we will walk through 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@@ -635,7 +636,7 @@ \caption{All |lhs2TeX| directives}\label{directives} \end{table} %-Many of these directive will be explained in more detail in the+Many of these directives will be explained in more detail in the following sections: \begin{compactitem}   \item See Section~\ref{sec:include} for the @%include@ directive.@@ -720,7 +721,7 @@  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+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@@ -728,7 +729,7 @@  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+processed separately by |lhs2TeX|, so you have to include @polycode.fmt@ (or @lhs2TeX.fmt@) in every single source file.  \begin{important}[Warning]@@ -766,13 +767,13 @@  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+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+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+some heuristics (cf.~Section~\ref{subsec:format-implicit}). Let us begin by looking at the first form.  %%%@@ -908,7 +909,7 @@ % 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}).+customizable, cf.~Section~\ref{sec:subst}).  %%% %%%@@ -1149,7 +1150,7 @@ 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+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. @@ -1181,7 +1182,7 @@       ``\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.+      (i.e.~at the same horizontal position) in the output. \end{compactitem} % Both latency and separation can be modified by means of associated@@ -1241,7 +1242,7 @@ 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.+Always verify the output to see 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@@ -1370,8 +1371,8 @@ \label{sec:variables} %--------------------------------------------------------------------------- -One can define or define flags (or variables) by means of the-@%let@ directive.+One can 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@@ -1419,8 +1420,8 @@ 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.+the else part of the conditional is processed by |lhs2TeX|, and the+rest is ignored.  %%% %%%@@ -1944,7 +1945,7 @@ \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.+document exactly as it has been entered, i.e.~verbatim. All spaces are preserved, and a non-proportional font is used. \input{Zip}%@@ -2032,7 +2033,7 @@ 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+unannotated code can be used to achieve good results, using the fonts you like while maintaining alignment information in the code!  %%%
doc/Guide2.pdf view

binary file changed (347055 → 441388 bytes)

+ doc/Interactive.lhs view
@@ -0,0 +1,29 @@+%include poly.fmt++%if False++> module Interactive where++%endif+%format . = "."+%format forall a = "\forall" a++> fix f = f (fix f)++%options ghci -fglasgow-exts+\textbf{ghci:}+This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.++%options hugs -98+\textbf{hugs:}+This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.++%options ghci-5.04.3 -fglasgow-exts+\textbf{ghci-5.04.3:}+This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.
+ doc/InteractiveHugs.lhs view
@@ -0,0 +1,27 @@+%include poly.fmt++%if False++> module InteractiveHugs where++%endif+%format . = "."+%format forall a = "\forall" a+%options hugs -98++> fix    ::  forall a. (a -> a) -> a+> fix f  =   f (fix f)++This function is of type +%if "" /= ""+\eval{:t fix},+%else+\textbf{?hugs not found?},+%endif+and |take 10 (fix ('x':))| +evaluates to+%if "" /= ""+\eval{take 10 (fix ('x':))}.+%else+\textbf{?hugs not found?}.+%endif
+ doc/InteractiveIn.lhs view
@@ -0,0 +1,21 @@+%include verbatim.fmt++\begingroup+\let\origtt=\ttfamily+\def\ttfamily#1{\origtt}+%if False+module Interactive where+%endif+%format . = "."+%format forall a = "\forall" a++\begin{code}+%options ghci -fglasgow-exts++> fix f = f (fix f)++This function is of type \eval{:t fix},+and |take 10 (fix ('x':))| +evaluates to \eval{take 10 (fix ('x':))}.+\end{code}+\endgroup
+ doc/InteractivePre.lhs view
@@ -0,0 +1,24 @@+%include poly.fmt++%if style == newcode++> module InteractivePre where++%endif+%format SPL(x) = $ ( x )+%if style == newcode+%format QU(x)  = [ | x | ]+%format ^^     = " "+%else+%format QU(x)  = "\llbracket " x "\rrbracket "+%format ^^     = "\; "+%endif++%options ghci -fth -pgmL "../lhs2TeX" -optL-Pdoc: -optL--pre++This is a rather stupid way of computing |42| using+Template Haskell:++> answer = SPL(foldr1 (\x y -> QU(SPL(x) + SPL(y))) (replicate 21 ^^ QU(2)))++The answer is indeed \eval{answer}.
+ doc/Map.lhs view
@@ -0,0 +1,12 @@+%include lhs2TeX.fmt++\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 _ _      _      =  []+\end{code}++
doc/RawSearchPath.lhs view
@@ -1,16 +1,17 @@ \begin{code} .-{HOME}/lhs2tex-1.22//+{HOME}/lhs2tex-1.23// {HOME}/lhs2tex// {HOME}/lhs2TeX//-{HOME}/.lhs2tex-1.22//+{HOME}/.lhs2tex-1.23// {HOME}/.lhs2tex// {HOME}/.lhs2TeX// {LHS2TEX}//-/usr/local/share/lhs2tex-1.22//-/usr/local/lib/lhs2tex-1.22//-/usr/share/lhs2tex-1.22//-/usr/lib/lhs2tex-1.22//+/usr/local/share/lhs2tex-1.23//+/usr/local/share/lhs2tex-1.23//+/usr/local/lib/lhs2tex-1.23//+/usr/share/lhs2tex-1.23//+/usr/lib/lhs2tex-1.23// /usr/local/share/lhs2tex// /usr/local/lib/lhs2tex// /usr/share/lhs2tex//
+ doc/STC.lhs view
@@ -0,0 +1,924 @@++\documentclass[10pt]{scrartcl}++% save linebreak; see below+\let\origlinebreak=\\++\renewcommand{\sectfont}{\bfseries}++\usepackage[english]{babel}+%\usepackage[inference]{semantic}+%\usepackage[fleqn]{amsmath}+\usepackage{stmaryrd}++\usepackage[code,screen,nopanel,sectionbreak]{pdfscreen}+\DeleteShortVerb{\||}++\usepackage{mathpazo}+\usepackage{colortbl}+\usepackage{calc}+\usepackage{pifont}+\usepackage{paralist}+%\usepackage{soul}+\usepackage{ifthen}+\usepackage{relsize}++%include lhs2TeX.fmt+%include lhs2TeX.sty++\newlength{\lwidth}+\newlength{\cwidth}+\setlength{\lwidth}{0pt}+\setlength{\cwidth}{0pt}++%separation 2+%latency 2++\let\origcolor=\color+\definecolor{hcolor}{rgb}{1,0,0}+\newcommand{\dep}[1]{{\origcolor{red}#1}}+\def\swgt#1{\switch[\value{step}>#1]}%+\def\ro#1{\ifthenelse{\value{step}=#1}{\origcolor{red}}{}}%++\setdefaultitem{\ding{217}}{}{}{}++\usepackage[display]{texpower}++%hyperref needs some setup, especially after pdfscreen+\hypersetup{%+  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}++\begin{screen}+  \margins{.3in}{.3in}{.3in}{.3in}  +  \screensize{3.75in}{4.8in}+  %\overlay{overlay1.pdf}+  \overlay{myov4.pdf}+  \setlength{\parindent}{0pt}+  \raggedright+\end{screen}++\setlength\pltopsep{2pt}+\setlength\plitemsep{1pt}+\setlength\parskip{0pt}++\newcounter{pagesave}++\def\BottomText{}+\def\slide{\ifthenelse{\value{pagesave}=\value{page}}{}{\def\BottomText{}}\section*}+\def\SkipToConclusionOption{%+  \setcounter{pagesave}{\value{page}}%+  \expandafter\def\expandafter\BottomText\expandafter{\BottomText+     \quad\hyperlink{SkipC}{(Skip to Conclusions)}}}+\def\SkipToSummaryOption{%+  \setcounter{pagesave}{\value{page}}%+  \expandafter\def\expandafter\BottomText\expandafter{\BottomText+     \quad\hyperlink{SkipS}{(Skip to Summary)}}}+\def\SkipTo#1#2{%+  \setcounter{pagesave}{\value{page}}%+  \expandafter\def\expandafter\BottomText\expandafter{\BottomText+     \quad\hyperlink{#1}{(#2)}\quad}}+\def\PrintDefault{{\tiny\color{section2}\raisebox{2ex}{\BottomText}}}+\makeatletter+\def\@@battrib{\color{section1}\footnotesize}+\def\@@@@buttons{\hfill\PrintDefault\hfill\vspace*{.15in}}+\def\TargetOnce#1#2{%+  \@@ifundefined{targetonce.#1}{%+    \message{targetting #1}%+    \hypertarget{#1}{#2}%+    \global\@@namedef{targetonce.#1}}{}{}}+\makeatother++\bottombuttons++\usepackage{polytable}+% 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" ++\newenvironment{colorcode}{%+  \parskip=\abovedisplayskip\par\noindent+  \begingroup\small% small changes displayskips!+  \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+  \let\\=\origlinebreak+  \(%+  \pboxed\SaveRestoreHook}{%+  \ColumnHook\endpboxed+  \)%+  \endtabular+  \endgroup+  \parskip=\belowdisplayskip\par\noindent+  \ignorespacesafterend}++\newenvironment{colorsurround}{%+  \parskip=\abovedisplayskip\par\noindent+  \begingroup\small% small changes displayskips!+  \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+  \let\\=\origlinebreak}{%+  \endtabular+  \endgroup+  \parskip=\belowdisplayskip\par\noindent+  \ignorespacesafterend}++\newenvironment{colorarray}{%+  \parskip=\abovedisplayskip\par\noindent+  \begingroup\small% small changes displayskips!+  \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+  \let\\=\origlinebreak+  \(%+  \array}{%+  \endarray+  \)%+  \endtabular+  \endgroup+  \parskip=\belowdisplayskip\par\noindent+  \ignorespacesafterend}++\makeatletter+\newenvironment{colorverb}{%+  \parskip=\abovedisplayskip\par\noindent+  \begingroup\small% small changes displayskips!+  \tabular{@@{}>{\columncolor{codecolor}}p{\linewidth}@@{}}%+  \let\\=\origlinebreak}{%+  \endtabular+  \endgroup+  \parskip=\belowdisplayskip\par\noindent+  \ignorespacesafterend}+\makeatother++%\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{\color{section0}Typesetting Haskell and more with @lhs2TeX@}+\author{{\color{section2}Andres L\"oh}\\+  Universiteit Utrecht\\+  \color{section2}\texttt{andres@@cs.uu.nl}}%+\date{September 8, 2004}+\maketitle++%%%+%%%++\slide{About @lhs2TeX@}++\begin{compactitem}+\item @lhs2TeX@ is a preprocessor+  \begin{compactitem}+  \item Input: a literate Haskell source file+  \item Output: a formatted file, depending on style of operation+  \end{compactitem}+\item Possible input:+\input{HelloWorldInput}+\end{compactitem}++%%%+%%%++\slide{Hello, world!}++\begin{compactitem}+\item @lhs2TeX@ is a preprocessor+  \begin{compactitem}+  \item Input: a literate Haskell source file+  \item Output: a formatted file, depending on selected style+  \end{compactitem}+\item Possible output:+\begin{colorsurround}+\input{HelloWorld}+\end{colorsurround}+\item From input to output:+\input{HelloWorldDialogue}+\end{compactitem}++%%%+%%%++\slide{Styles}++\begin{compactitem}+\item @lhs2TeX@ has several styles with different behaviour:+  \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}+\end{compactitem}++%%%+%%%++\slide{Example of ``verb'' style}++\input{Zip}++%%%+%%%++\slide{Example of ``tt'' style}++\input{ZipTT}++Differences from \textbf{verb} style:+\begin{compactitem}+\item Some of Haskells symbols can be expressed more naturally.+\item Keywords can be highlighted.+\end{compactitem}++%%%+%%%++\slide{Drawback of formatting}++\input{ZipStupid}++\begin{compactitem}+\item Alignment information is lost.+\end{compactitem}++%%%+%%%++\slide{Example of ``math'' style}++\input{ZipMath}++\begin{compactitem}+\item Only one alignment column, plus indentation.+\end{compactitem}++%%%+%%%++\slide{Example of ``poly'' style}++\input{ZipPoly}+\begin{compactitem}+\item Complex layouts are possible.+\end{compactitem}++%%%+%%%++\slide{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}++%%%+%%%++% End of introduction part -- begin of reference++%%%+%%%++\slide{@lhs2TeX@ operation}++\begin{compactitem}+\item When given an input file, @lhs2TeX@ does only look at the following+      constructs:+\begin{compactitem}+\item Directives.+\item Text between two \verb+@+ characters. Such text is considered inline+      verbatim. Any \verb+@+ in the source file needs to be escaped: \verb+@@+.+\item Text between two @|@ characters. Such text is considered inline code.+\item Lines indicating a Bird-style literate program (i.e. lines beginning+      with either @>@ or @<@) are considered as code blocks.+\item Lines surrounded by @\begin{code}@ and @\end{code}@ statements, or+      by @\begin{spec}@ and @\end{spec}@ statements, are considered as+      code blocks.+\end{compactitem}+\item Everything else is considered plain text and either ignored +      (for \textbf{verb}, \textbf{tt}, \textbf{math}, and \textbf{poly})+      or discarded (for \textbf{code} and \textbf{newcode}).+\end{compactitem}++%%%+%%%++\slide{Directives}++\begin{compactitem}+\item+@lhs2TeX@ interprets a number of directives. ++\item+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.++\item+These are the directives we will learn about in this talk:+\input{Directives}+\end{compactitem}++%%%+%%%++\slide{Including files}++\begin{compactitem}+\item Other files can be included by @lhs2TeX@. +      \input{IncludeSyntax}+\item Using @%include@, not only other sources, but also other directives+      can be included. ++\item The specified file is searched for in the @lhs2TeX@+      source path which can be modified using environment variables or+      the @-P@ command line option.++\item Included files are inserted literally at the position of the+      @%include@ directive. The @lhs2TeX@ inclusion is therefore+      entirely independent of \TeX\ or Haskell includes/imports.+\end{compactitem}++%%%+%%%++\slide{The @lhs2TeX@ ``prelude''}++\begin{compactitem}+\item Several aspects of the behaviour of @lhs2TeX@ are not hardcoded,+      but configurable via directives.+\item A minimal amount of functionality has to be defined so that @lhs2TeX@+      can operate usefully.+\item Essential definitions are collected in two files, @lhs2TeX.fmt@+      (containing basic directives) and @lhs2TeX.sty@ (containing basic+      \LaTeX\ setup). These two files should be included -- directly or +      indirectly -- in every file to be processed by @lhs2TeX@!+      \input{IncludePrelude}+\item It is perfectly possible to design own libraries that replace or extend+      these basic files and to include those own libraries instead.+\end{compactitem}++%%%+%%%++\slide{Formatting}++\begin{compactitem}+\item Using the @%format@ directive, tokens can be given a different+      appearance.+      \input{FormatSyntax}+\item Let us look at a couple of examples.+\end{compactitem}++%%%+%%%++\slide{Formatting identifiers}++\begin{compactitem}+\item Input:+      \input{FormatGreekIn}+\item Output:+      \input{FormatGreekOut}+\end{compactitem}++%%%+%%%++\slide{Parametrized formatting directives}++\begin{compactitem}+\item Formatting directives can be parametrized. The parameters may occur+      once or more on the right hand side.+\item Input:+      \input{CardIn}+\item Output:+      \begin{colorsurround}+      \input{Card}+      \vspace*{-2\baselineskip}%+      \end{colorsurround}+\end{compactitem}++%%%+%%%++\slide{Parentheses}++\begin{compactitem}+\item Sometimes, due to formatting, parentheses around arguments or the entire+      function become unnecessary.+\item 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.+\item Parentheses around the entire function are dropped if the entire left hand side+      of the directive is enclosed in parentheses.+\end{compactitem}++%%%+%%%++\slide{Parentheses -- example}++\begin{compactitem}+\item Input:+      \input{ParensExampleIn}+\item Output:+      \begin{colorsurround}+      \input{ParensExample}+      \vspace*{-2\baselineskip}%+      \end{colorsurround}+\end{compactitem}++%%%+%%%++\slide{Parentheses -- example}++\begin{compactitem}+\item Input:+      \input{ParensExample2In}+      +\item Output:+      \begin{colorsurround}+      \input{ParensExample2}+      \vspace*{-2\baselineskip}%+      \end{colorsurround}+\end{compactitem}+++%%%+%%%++\slide{Local formatting directives}++\begin{compactitem}+\item Usually, formatting directives scope over the rest of the input.+\item Formatting directives can be placed into \textbf{groups}.+      \input{GroupSyntax}+\item Formatting directives that are defined in a group scope only over+      the rest of the current group. +\end{compactitem}++%%%+%%%++\slide{Local formatting directives -- example}++\begin{compactitem}+\item Input:+      \input{GroupExampleIn}+\item Output:+      \begin{colorsurround}+      \input{GroupExample}+      \end{colorsurround}+\end{compactitem}++%%%+%%%++\slide{Nested applications of formatting directives}++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}++%%%+%%%++\slide{Implicit formatting}++\begin{compactitem}+\item A variable (or constructor) name that ends in a number or a prime @'@+      can be used in an implicit formatting statement.+\item The prefix will 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.+\end{compactitem}++%%%+%%%++\slide{Implicit formatting -- example}++\begin{compactitem}+\item Input:+      \input{ImplicitIn}+\item Output:+      \begin{colorsurround}+      \input{Implicit}+      \end{colorsurround}+\end{compactitem}++%%%+%%%++\slide{Formatting in the various 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 apply.+\item In \textbf{verb} and \textbf{code} styles, formatting directives are ignored.+\end{compactitem}++%%%+%%%++\slide{Alignment in ``poly'' style}++\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.+\item (Almost) everything is possible, but watch out for +      accidental alignments!+\end{compactitem}+      +%%%+%%%++\slide{Alignment example}++\begin{compactitem}+\item Input:+      \input{RepAlgIn}+\item The red {\origcolor{red} @lt@} is not aligned+      (only one preceding space).+\item Output:+      \input{RepAlg}+\end{compactitem}++%%%+%%%++\slide{Accidental alignment example -- input}++\input{AccidentalIn}++\begin{compactitem}+\item+  The red items will be unintentionally aligned because+  they start on the same column, with two or more preceding spaces+  each.+\item+  To correct, insert extra spaces to ensure that unrelated+  tokens start on different columns.+\end{compactitem}++%%%+%%%++\slide{Accidental alignment example -- continued}++\begin{compactitem}+\item Output:+      \input{Accidental}++\item Corrected version:+      \input{AccidentalC}+\end{compactitem}++%%%+%%%++%if False+\slide{Tweaking the alignment behaviour}++\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 @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 +      @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.+\item It can be useful to increase the default settings of 2 and 2 for+      large code blocks where accidental alignments become very likely!+\end{compactitem}++\input{SepLatSyntax}+%endif++%%%+%%%++\slide{Indentation in ``poly'' style}++\begin{compactitem} +\item If a line is indented in column |n|, then+the \textbf{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 indendet with respect to the+        first aligned token in the previous line to the left of column |n|.+  \end{compactitem}+\end{compactitem}++%%%+%%%++\slide{Indentation in ``poly'' style -- example}++\begin{compactitem}+\item Input:+      \input{Indent1In}+\item Output:+      \input{Indent1}+\item In this example, there is an aligned token in the previous line+      at the same column, so everything is normal.+\end{compactitem}++%%%+%%%++\slide{Indentation in ``poly'' style -- example}++\begin{compactitem}+\item Input:+      \input{Indent2In}+\item Output:+      \input{Indent2}+\item In this example, 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.+\end{compactitem}++%%%+%%%++\slide{Indentation in ``poly'' style -- example}++\begin{compactitem}+\item Input:+      \input{Indent3In}+\item Output:+      \input{Indent3}+\item In rare cases, the indentation heuristic can lead to surprising+      results. Here, the |1| is aligned with the |2|, but |2| is also+      indented with respect to |bar|.+\end{compactitem}+++%%%+%%%++\slide{Advanced alignment topics}++\begin{compactitem}+\item Some columns (containing symbols) are centered by @lhs2TeX@+      (all other columns are left-aligned).+\item It is possible redefine the alignment of a specific column.+\item It is possible to customize the output environment (using+      @%subst@ directives). Using this, one can produce effects+      such as putting all code blocks into yellow boxes.+\item It is possible to save (and restore) column information.+\end{compactitem}++%%%+%%%++\slide{Saving and restoring column information\\ example -- input}++\input{SaveRestoreIn}++%%%+%%%++\slide{Saving and restoring column information\\ example -- output}++\input{SaveRestore}++%%%+%%%++\slide{Spacing}++\begin{compactitem}+\item @lhs2TeX@ does not really have a Haskell parser.+\item Because of this, it can be used for dialects of Haskell, too!+\item Spacing is handled automatically so that it works for correctly+      for pure Haskell most of the time.+\item A good trick is to define the following two pseudo-operators+      to correct wrong automatic spacing:+      \input{SpacingOps}+      \begin{compactitem}+      \item Use @^@ where you do \textbf{not} want a space, but @lhs2TeX@+            would place one.+      \item Use @^^@ where you \textbf{do} want a space, but @lhs2TeX@+            does not place one.+      \end{compactitem}+\end{compactitem}++%%%+%%%++\slide{{\smaller AG} code example -- input}++\input{AGExampleIn}++%%%+%%%++\slide{{\smaller AG} code example -- output}++\input{AGExample}++%%%+%%%++\slide{Calculation example -- input}++\vspace*{-\baselineskip}++\input{CalcExampleIn}++%%%++\slide{Calculation example -- output}++\input{CalcExample}++%%%+%%%++\slide{Defining variables}++\begin{compactitem}+\item @lhs2TeX@ allows flags (or variables) to be set by means of the+  @%let@ directive.+  \input{LetSyntax}+\item Expressions are built from booleans (either @True@ or @False@),+  integers, strings and previously define variables using some predefined, +  Haskell-like operators.+\item Variables can also be defined by using the @-l@ or @-s@+  command line options.+\item @lhs2TeX@'s version is available as predefined @version@ variable,+  and the current style is available as predefined @style@ variable.+\end{compactitem}++%%%+%%%++\slide{Conditionals}++\begin{compactitem}+\item (Boolean) expressions can also be used in conditionals:+  \input{IfSyntax}+  The @%elif@ and @%else@ directives are optional.+\item Depending on the result of the evaluation of the expression,+  only the then or the else part are processed by @lhs2TeX@.+\end{compactitem}++%%%+%%%++\slide{Uses of conditionals}++\begin{compactitem}+\item Have different versions of one paper in one source. Depending+      on a flag, produce either the one or the other. Because the+      flag can be defined via a command line option, 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, \textbf{or:}+\item If Haskell code has to be annotated for @lhs2TeX@ to produce+      the right output, 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!+\end{compactitem}++%%%+%%%++\slide{Calling @ghci@}++\begin{compactitem}+\item It is possible to call @ghci@ (or @hugs@) using the @%options@+      directive. +\item @lhs2TeX@ looks for calls to the \textbf{\TeX\ commands}+      @\eval@ and @\perform@ and feeds their arguments to the+      interpreter.+\item The current input file will be the active module. Therefore,+      this feature works only if the current file really is legal+      Haskell.+\end{compactitem}++%%%+%%%++\slide{Calling @ghci@ -- example}++\begin{compactitem}+\item Input:+      \input{InteractiveIn}+\item Output:+      \begin{colorsurround}+      \input{InteractiveGhci}+      \end{colorsurround}+\end{compactitem}++%%%+%%%++\slide{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 the Subversion repository.+\item It is reported to work on Linux, Mac OS X, and Windows.+\item It has been used for several papers and seems to be quite stable.+\end{compactitem}++%%%+%%%++\slide{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!++\end{document}++%%%+%%%++\slide{Test}++\input{Variable}+++%%%+%%%++\slide{@poly@-style is customizable}++\input{ZipPolyTT}+++++\end{document}+
lhs2tex.cabal view
@@ -1,6 +1,6 @@ cabal-version:  >=1.10 name:           lhs2tex-version:        1.22+version:        1.23 license:        GPL license-file:   LICENSE author:         Ralf Hinze <ralf.hinze@comlab.ox.ac.uk>, Andres Loeh <lhs2tex@andres-loeh.de>@@ -24,7 +24,7 @@   be invoked in another mode to just extract the Haskell code. category:       Development, Language build-type:     Custom-tested-with:    GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.1, GHC == 8.4.3, GHC == 8.6.1+tested-with:    GHC == 7.4.2, GHC == 7.6.3, GHC == 7.8.4, GHC == 7.10.3, GHC == 8.0.2, GHC == 8.2.2, GHC == 8.4.4, GHC == 8.6.5, GHC == 8.8.1 extra-source-files:     AUTHORS                         CHANGELOG.md                         INSTALL@@ -85,6 +85,7 @@                         filepath,                         directory,                         process+  autogen-modules:      Version   other-modules:        Auxiliaries                         Directives                         Document
src/HsLexer.lhs view
@@ -7,7 +7,7 @@ > {-# LANGUAGE NPlusKPatterns #-} > module HsLexer                (  module HsLexer ) --Token(..), isVarid, isConid, isNotSpace, string, tokenize  ) > where-> import Data.Char      (  isSpace, isUpper, isLower, isDigit, isAlphaNum, isPunctuation  )+> import Data.Char      (  isSpace, isUpper, isLower, isDigit, isAlphaNum, isPunctuation, toLower ) > import qualified Data.Char ( isSymbol ) > import Control.Applicative > import Control.Monad@@ -123,6 +123,12 @@ > lex' _lang ('{' : '-' : s)    =  do let (t, u) = nested 0 s >                                     v <- match "-}" u >                                     return (Nested t, v)+> lex' _lang ('0' : d : s)+>     -- octal and hexademical literals, see #74+>     -- Agda seems to support hex but not octal, but it seems harmless and easiest to me to+>     -- support this for both languages+>     | d `elem` "oO"           =  let (t, u) = span isOctDigit s in return (Numeral ('0' : d : t), u)+>     | d `elem` "xX"           =  let (t, u) = span isHexDigit s in return (Numeral ('0' : d : t), u) > lex' lang  (c : s) >     | isSpace c               =  let (t, u) = span isSpace s in return (Space (c : t), u) >     | isSpecial lang c        =  Just (Special c, s)@@ -218,6 +224,10 @@ > isSymbol Agda c               =  isIdChar Agda c > isIdChar Haskell c            =  isAlphaNum c || c `elem` "_'" > isIdChar Agda c               =  not (isSpecial Agda c || isSpace c)++> isOctDigit, isHexDigit        :: Char -> Bool+> isOctDigit c                  =  c `elem` "01234567"+> isHexDigit c                  =  isDigit c || toLower c `elem` "abcdef"  > match                         :: String -> String -> Maybe String > match p s
src/License.lhs view
@@ -8,7 +8,7 @@  > programInfo                   :: String > programInfo                   =->     "lhs2TeX " ++ version ++ ", Copyright (C) 1997-2017 Ralf Hinze, Andres Loeh\n\n\+>     "lhs2TeX " ++ version ++ ", Copyright (C) 1997-2020 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\