Avoid blank line separating code and comments in Bird style?
Richard Eisenberg
eir at cis.upenn.edu
Wed Jan 14 15:55:41 UTC 2015
I think the underlying problem here is that there is a difference between "literate" comments and "normal" comments.
In a bird-style literate Haskell file, this is what I'll call a literate comment:
~~~
A line with no marker at the beginning
~~~
A normal comment is in a line of Haskell code, put with a comment indicator:
~~~
> -- This is a "normal" comment
~~~
When GHC sees a bird-style literate Haskell file, it first strips out all lines that don't begin with >. Then, it starts doing its real work, including parsing Haddock comments. So, to use a Haddock comment in a literate Haskell file, you'd need to use the "normal" comment style:
~~~
> -- | Make a numbered widget
> mkWidget :: Int -> Widget
~~~
There is no way to use Haddock markup in a "literate" comment.
But, as Mateusz points out, there may be blank lines between the Haddock comment and the thing being described:
~~~
> -- | Get the number of a widget
>
> widgetNum :: Widget -> Int
~~~
I hope this clarifies things!
Richard
On Jan 14, 2015, at 2:42 AM, sidhu1f <sidhu1f at gmail.com> wrote:
> At Wed, 14 Jan 2015 12:31:54 +0530,
> Mateusz Kowalczyk wrote:
>
>> I imagine you're suggesting that something like
>
>> Literate comment
>>> someCode = undefined
>
> This (literate comment followed by code with no intervening blank
> line) is exactly what I want (regret my explanation was unclear). But
> when I try it, GHC reports the error 'unlit: Program line next to
> comment'.
>
>> is allowed ...
>
> As you mention above behaviour is allowed, could you let me know how
> to enable it?
>
> Regards
> Sidhu
> _______________________________________________
> Glasgow-haskell-users mailing list
> Glasgow-haskell-users at haskell.org
> http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
More information about the Glasgow-haskell-users
mailing list