In this space you can use lhs2TeX, which has many options, but can give good results when formatting. It has fairly extensive documentation, which you can find on the home page .
An example of use (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}
\documentclass{article}
, \begin{document}
and \end{document}
are all TeX commands to indicate which document you need and where it starts / ends.
%include polycode.fmt
is actually a comment in TeX, but will tell lhs2TeX what format to use when processing the .lhs
file.
You can compile an example with
$ lhs2TeX -o HelloWorld.tex HelloWorld.lhs $ pdflatex HelloWorld.tex
For HTML, you can also try Pandoc , which can provide you with all kinds of output formats (pdf, html, rtf, etc.).
source share