How to I convert a Literate Haskell file to something easier on the eyes? Here's what happens when I try to do the obvious thing:
$ latex Check.lhs
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
entering extended mode
(./Check.lhs
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, loaded.
! LaTeX Error: Environment code undefined.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.7 \begin{code}
I'm not familiar with the usual commands for processing tex files. What's a simple, no-nonsense way I can use to convert just about any .lhs
file to e.g. PDF or HTML?
In this space you can use lhs2TeX, which has quite a few options but can give quite nice results on formatting. It has pretty extensive documentation, which you can find on the homepage.
An example of usage (directly from the manual) would be
\documentclass{article}
%include polycode.fmt
\begin{document}
This is the famous ‘‘Hello world’’ example,
written in Haskell:
\begin{code}
main :: IO ()
main = putStrLn "Hello, world!"
\end{code}
\end{document}
The \documentclass{article}
, \begin{document}
and \end{document}
are all TeX commands to indicate what kind of document you want, and where it starts/ends.
The %include polycode.fmt
is actually a comment in TeX, but will indicate to lhs2TeX what format to use when processing the .lhs
file.
You can compile the example with
$ lhs2TeX -o HelloWorld.tex HelloWorld.lhs
$ pdflatex HelloWorld.tex
For HTML you can also try Pandoc, which can give you all sorts of output formats (pdf, html, rtf, etc).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With