[Haskell-cafe] Problem with Haddock

Simon Marlow simonmar at microsoft.com
Tue Mar 8 11:45:01 EST 2005


On 08 March 2005 15:26, Daniel Fischer wrote:

> I have the problem that I can't haddock literate modules
> (latex-style), 
>> haddock -h -o docs Test.lhs
> Test.lhs:1:1: Parse error
> 
> the file begins with "\begin{code}".
> 
> Does anybody know what's up and what to do about it?

Haddock doesn't understand literate files on its own.  The documentation
describes how to get around this... er, well the documentation in CVS
describes how to get around this, but the 0.6 docs on the web don't.
Here's the relevant text:

    <section id="cpp">
      <title>Using literate or pre-processed source</title>

      <para>Haddock only accepts plain, non-literate, Haskell source.
      This means that if you program in Literate Haskell, or you need
      to use the C pre-processor in your Haskell source, then you need
      to pre-process the files before feeding them to Haddock.  This
      is easily accomplished using GHC; for example, suppose we have a
      Literate Haskell source file <filename>Foo.lhs</filename>, on
      which we also need to run the C pre-processor:</para>

<screen>
$ ghc -cpp -E -optP-P -D__HADDOCK__ Foo.lhs -o Foo.hs
$ haddock -h Foo.hs ...
</screen>

      <para>The <option>-E</option> option to GHC says "stop after
      pre-processing", the <option>-cpp</option> option turns on the C
      pre-processor, the <option>-optP-P</option> option tells the C
      pre-processor not to leave any extra dropping behind (see the
      description of the <option>-P</option> option in the gcc manual
      for details), and the <option>-D__HADDOCK__</option> option
      defines the symbol <literal>__HADDOCK__</literal> when
      pre-processing (this is sometimes handy if you need to any
      pre-processing conditionals in your source which depend on
      whether the source is going to be fed to Haddock).</para>
    </section>

Cheers,
	Simon


More information about the Haskell-Cafe mailing list