kosmikus / lhs2tex

Preprocessor for typesetting Haskell sources with LaTeX
Other
99 stars 28 forks source link

The arguments to a parametrized directive are not recognized with --agda after one use #63

Open carlostome opened 6 years ago

carlostome commented 6 years ago

Compiling the following code,

\documentclass{article}
%include lhs2TeX.fmt
%include lhs2TeX.sty
%include polycode.fmt

%{
%format abs (a) = "\mathopen{|}" a "\mathclose{|}"

\begin{document}
\begin{code}
  abs(1) = abs(2)
\end{code}
\end{document}
%}

with lhs2TeX --poly produces the expected result, |1| = |2|, whereas lhs2TeX --agda does not recognize the argument to the second use of abs producing |1| = |.| (2).

kosmikus commented 6 years ago

This looks like a real bug, unfortunately.

A workaround might be to define

%format (abs (a)) = "\mathopen{|}" a "\mathclose{|}"

instead and then

abs(1) = (abs(2))

I suspect that even = is considered by the lhs2tex Agda lexer as a valid argument, so that the whole line is parsed as the first abs being applied to four arguments ...