patch applied (ghc): Adding a GENERATED pragma

Simon Marlow simonmarhaskell at gmail.com
Thu Jan 4 05:03:35 EST 2007


Andy Gill wrote:
>>
>> LINE can already refer to an external non-.hs file. This is exactly  how
>> things works now with all manner of pre-processors, alex, happy,  cpphs,
>> c2hs, hsc2hs, etc.
>>
>> I don't quite have an intuition for this yet, can you give an  example of
>> how this more fine grained pragma works and some use-case not  currently
>> covered by LINE?
>>
> 
> Ahhh. LINE does? Oh.
> 
> - GENERATED works on an expression based level, and can specify  
> specific spans.
>   (20:4 - 21:8, for example).

often LINE can be used to do this - you just have to put the expression on a 
line by itself.

GENERATED would seem to be useful if the preprocessor modifies the column 
numbers, not just the line numbers, of Haskell code in the original source text. 
  Happy is careful not to do this: we retain the indentation of the code inside 
{ .. }, if I recall correctly (or if not, we should :-).

>  - GENERATED is a true pragma; it hints where things come from, but  
> does not change
>   the error message. I want the Haskell source spans to remain  unchanges.

I don't get this - could you elaborate?

Andy - can you give us an idea of your use case for GENERATED?

If we do need this, then I suggest either {-# COL #-} for specifying the source 
column number and/or {-# SPAN #-} for specifying a span (which presumably 
specifies the span of the following syntactic entity, which we'd have to define 
precisely).

Cheers,
	Simon




More information about the Cvs-ghc mailing list