concrete syntax for role annotations

Simon Peyton-Jones simonpj at
Fri Aug 23 10:23:30 CEST 2013

(Adding ghc-devs, who will, I hope, have opinions)

I'm sympathetic to this.  In general our story for pragmas {-# blah #-} is that they affect only optimisation (eg INLINE) or warnings (eg DEPRECATED).  You can ignore/leave them out. But here you really can't.  Well, I suppose leaving out the annotation does not risk soundness (as in run-time seg-fault); it just risks sets being ordered wrong.

I don't have a strong opinion here.

You could also imagine other syntaxes e.g.
                data Set a(role N) = ...
I suppose.

You are right that we need to get this nailed for 7.8, so we don't end up changing it later.


From: Richard Eisenberg [mailto:eir at]
Sent: 23 August 2013 05:52
To: Simon Peyton-Jones; Dimitrios Vytiniotis; Stephanie Weirich
Subject: concrete syntax for role annotations

Hi all,

On a Reddit discussion of my recent blog post on roles (, it was suggested that a better syntax is available for specifying role annotations.

Currently, I've implemented

> data Set a at N = ...

to mark Set's parameter's role as N. The suggested syntax is

> data Set a {-# ROLE N #-} = ...

This suggested syntax is certainly much more verbose, but it's fully backwards-compatible, avoiding the need for preprocessing statements in libraries. These annotations should hopefully be few and far between, and I just think it's worth considering the backwards-compatible syntax before 7.8 is released and we're stuck.

What do we think? Should I forward the question to glasgow-haskell-users, perhaps?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the ghc-devs mailing list