@hackage latex-live-snippets0.1.0.0

Automatically inline Haskell snippets into LaTeX documents.

latex-live-snippets

Install with stack install, and then in latex via:

% set this to where your code is
\newcommand{\srcdir}{.}

\newcommand{\snip}[2]{\immediate\write18{latex-live-snippets \srcdir/#1.hs #2}\input{.latex-live-snippets/#1.#2.tex}}

Now, given a file Test.hs:

zoo :: Int
zoo = 5

test :: Bool -> Bool
test True = id $ True
test _    = True  -- ! 1

we can call

\snip{Test}{test}

which will result in:

\begin{code}
test :: Bool -> Bool
test True = id \$ True
test \_    = True \ann{1}
\end{code}

It will also find type families, data definitions. Custom snippet areas can be defined via comments of the form -- # name.