Annotations

Gergely Risko gergely at risko.hu
Wed Nov 6 11:57:14 UTC 2013


On Wed, 6 Nov 2013 10:55:09 +0000, Simon Peyton-Jones <simonpj at microsoft.com> writes:

> I’m inclined to add a language extension “Annotations”. 
>
> · Without it {-# ANN … #-} pragmas are ignored as comments
>
> · With it, they are treated as annotations
>
> Do you agree?

I generally agree that this should be a language extension.

My only worry is around the just implemented TH additions regarding
annotations.  I don't clearly see what would happen if:
  - a TH library exports a function that generates annotations when spliced.
  - and the user uses this function in a .hs file,
  - without specifying the language extension.

I'd it to work even in that case.

I guess the behavior in this corner case depends heavily on how this is
actually implemented.  If e.g. the reader is the only component that
checks if the language extension is turned on, then I imagine that the
TH way of putting in the annotation into the AST would just work.

On the other hand if the reader recognizes the annotations either way
and some component after TH splicing is checking for the language
extension, then my use-case would blow up.

TH currently is lenient in cases like this.  E.g. if you know that a
Name is exported from a module and you reference it directly, without
importing it everything will just work.  I'd like to have the same
behavior for annotations.

Thanks,
Gergely



More information about the ghc-devs mailing list