How do I get the appropriate vertical space around a \begin{code}/\end{code} or \begin{spec}/\end{spec} in a figure?
Here is a basic example with fancyhdr added to show the top of the page:
\documentclass{article}
\usepackage{fancyhdr} \pagestyle{fancy} \fancyhf{} \fancyhead[C]{}
%include polycode.fmt
\begin{document}
Some text.
\begin{figure}[t]
\begin{code}
main = putStrLn "Hello, world!"
\end{code}
\caption{Hello world example}
\end{figure}
\end{document}

Unfortunately, when you compare this figure to another without code, the spacing above and below the code is noticeably more.
When looking at the code of lhs2TeX, I noticed the use of \abovedisplayskip
and \belowdisplayskip. So I tried setting those to 0pt:
...
\begin{figure}[t]
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\begin{code}
...

This looks more like other figures with just text. However, if I want to center the code, I get extra vertical space again:
...
\begin{figure}[t]
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}
\begin{center}
...

What's the recommended way to get the appropriate vertical spacing around a (possibly centered) code block in a figure?
\abovedisplayskipand\belowdisplayskip. The centering seems to have the same space-increasing effect on plain text and code blocks, which suggests that it is independent of lhs2TeX. Any idea about how to fix that? – Sean Leather Jun 24 '14 at 10:30\centeringinstead of\begin{center}/\end{center}inside a float. – Sean Leather Jun 24 '14 at 10:34