Avoid blank line separating code and comments in Bird style?

sidhu1f sidhu1f at gmail.com
Wed Jan 14 16:54:35 UTC 2015


At Wed, 14 Jan 2015 10:55:41 -0500,
Richard Eisenberg wrote:
> 
> 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 understand and agree with all you say above...
 
> I hope this clarifies things!

...but unfortunately it doesn't solve my problem. I guess my attempt
to motivate with the Haddock use case confused things.

What I want to do has nothing to do with Haddock. All I would like is,
very simply (in Bird style) literate comment and code next to each
other with No Intervening Blank Lines separating them. But GHC doesn't
accept this and GHC reports the error 'unlit: Program line next to
comment'. If I add a blank line between the literate comment and code,
GHC accepts it.

Summarizing, following is accepted by GHC without error (notice blank
line separating literate comment and code):

   literate comment
   
   > haskell code

For following GHC reports error, but it is what I require:

   literate comment
   > code

So. Is there any way GHC can be coaxed to accept a Bird style literal
Haskell file with no blank line separating code and literal comment?

> Richard
> 

Sidhu


> 
> 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