[Haskell-cafe] Help with lhs2TeX

Ralf Hinze ralf.hinze at comlab.ox.ac.uk
Sat Dec 11 12:44:48 CET 2010


Hi Dominic,

> Hi, I wonder if someone could point out what I am doing wrong. My
> understanding was that I should be able to create a .lhs file and run it
> e.g. with ghci and then use lhs2TeX to create a nice .pdf file, all from
> the same source. I can produce nice slides but unfortunately the .lhs
> does compile because of the special symbols I wish to use. So presumably
> I need to pre-process my file before submitting to ghci. However, I was
> unable to find any information about this in the excellent guide. For
> example:
> 
> > \documentclass{beamer}
> >
> > %include polycode.fmt
> > %format m_ = "\mu"
> > %format ^ = " "
> > %format inv(a) = a^"^\circ"
> > %format in_ = "in"
> >
> > \begin{document}
> >
> > \title{Some Notes on Category Theory with Some Applications to Computer
> >   Science}
> >
> > \author{Dominic Steinitz}
> >
> > \begin{frame}
> >   \frametitle{Haskell Example: Total}
> > Initial algebras can be defined as follows:
> > \begin{code}
> > newtype m_^f = In {inv(in_) :: f (m_^f )}
> > \end{code}
> > \end{frame}
> >
> >
> > \end{document}
> produces a nice slide but does not compile.
> 
> If I change the offending line to
> 
> > newtype Mu f = In {in_ :: f (Mu f)}
> then all is well but the slide does not look as nice

the basic approach (originally) is to have an executable Haskell program
so that you can typecheck it. Then you add some %format directives to make
it look nice, eg.

%format Mu f = "\mu" f
%format in_ = "in^\circ"

should do the job.

Hth, Ralf
 



More information about the Haskell-Cafe mailing list