<div dir="ltr"><div>Dear Oleg,</div><div><br></div><div>Thanks for the reply! It works modulo line 24 where, it seems, your mail client broke the line which happened to be inside comment and that drives pdflatex mad. The gist is fine though, so I put the link here:</div><div><a href="https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex">https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex</a></div><div><br></div><div>Your answer shows the approach one could apply to tune the color of various lexical element. I wonder if there are prebaked set of definitions covering the whole (or most of) grammar: literals, comments, type variables…  {- Obviously, RIchard has one :) -}<br></div><div><br></div><div>--</div><div>Best, Artem<br></div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, 21 Jun 2018 at 19:22 Oleg Grenrus <<a href="mailto:oleg.grenrus@iki.fi">oleg.grenrus@iki.fi</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Artem,<br>
<br>
I answer with inline lhs2Tex file. Hopefully it helps in your typed-code<br>
type-settings!<br>
<br>
cheers, Oleg.<br>
<br>
\documentclass{article}<br>
%include polycode.fmt<br>
<br>
\usepackage{hyperref}<br>
\hypersetup{pdfborder={0 0 0}}<br>
<br>
% in lhs2TeX.style there are<br>
%<br>
% \newcommand{\Conid}[1]{{\mathit #1}}<br>
% \newcommand{\Varid}[1]{{\mathit #1}}<br>
% \newcommand{\anonymous}{\_}<br>
%<br>
% We can renew these<br>
<br>
\usepackage{xcolor}<br>
\definecolor{darkred}{rgb}{.5,0,0}<br>
\definecolor{darkgreen}{rgb}{0,0.5,0}<br>
\definecolor{darkblue}{rgb}{0,0,.5}<br>
\definecolor{color4}{rgb}{0,.4,.4}<br>
\definecolor{color5}{rgb}{.4,.4,0}<br>
<br>
\renewcommand{\Conid}[1]{{\color{darkblue}\mathit #1}}<br>
<br>
% however types and constructors look the same, we can differentiate<br>
them though<br>
<br>
%format Foo = "{\color{darkred}\mathit Foo}"<br>
%format MkFoo = "{\color{darkgreen}\mathit Foo}"<br>
<br>
% Note how I "cheat" making MkFoo render as Foo!<br>
<br>
% We can also highlight operators<br>
%format + = "\mathbin{\color{color4}+}"<br>
<br>
% or symbols (note I also make thing look prettier)"<br>
%format plusFoo = "{\color{color5}\mathit plus_{Foo}}"<br>
%format ColorsInLhs2TeX = "{\text{Colors in lhs2\TeX}}"<br>
<br>
\begin{document}<br>
<br>
An example of colorful lhs2\TeX\ file.<br>
See the source at<br>
\url{<a href="https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex%7D%" rel="noreferrer" target="_blank">https://github.com/phadej/gists/blob/master/posts/2018-06-21-colors-in-lhs2tex.tex}%</a><br>
\footnote{It's named tex to trick \emph{Pandoc} in my blog setup},<br>
and the result PDF at<br>
\url{<a href="https://github.com/phadej/gists/blob/master/pdf/ColorsInLhs2TeX.pdf" rel="noreferrer" target="_blank">https://github.com/phadej/gists/blob/master/pdf/ColorsInLhs2TeX.pdf</a>}<br>
<br>
\begin{code}<br>
module ColorsInLhs2TeX where<br>
<br>
newtype Foo = MkFoo Int<br>
<br>
plusFoo :: Foo -> Foo -> Int<br>
plusFoo (MkFoo n) (MkFoo m) = n + m<br>
\end{code}<br>
\end{document}<br>
<br>
<br>
On 21.06.2018 18:29, Artem Pelenitsyn wrote:<br>
> Dear Cafe,<br>
><br>
> In his recent Stitch manuscript,<br>
> <a href="https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf" rel="noreferrer" target="_blank">https://cs.brynmawr.edu/~rae/papers/2018/stitch/stitch.pdf</a><br>
> <<a href="https://cs.brynmawr.edu/%7Erae/papers/2018/stitch/stitch.pdf" rel="noreferrer" target="_blank">https://cs.brynmawr.edu/%7Erae/papers/2018/stitch/stitch.pdf</a>><br>
> Richard Eisenberg mentions that he uses lhs2TeX to typeset Haskell<br>
> listings, but I'm not aware of the support for colors in lhs2TeX. Can<br>
> anyone suggest how to get such a nice code highlighting (presumably<br>
> with lhs2TeX).<br>
><br>
> --<br>
> Best wishes,<br>
> Artem<br>
><br>
><br>
> _______________________________________________<br>
> Haskell-Cafe mailing list<br>
> To (un)subscribe, modify options or view archives go to:<br>
> <a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
> Only members subscribed via the mailman list are allowed to post.<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>