[GHC] #8185: Change role annotation syntax
GHC
ghc-devs at haskell.org
Thu Sep 5 18:41:00 CEST 2013
#8185: Change role annotation syntax
----------------------------+----------------------------------------------
Reporter: | Owner: goldfire
goldfire | Status: new
Type: feature | Milestone: 7.8.1
request | Version: 7.7
Priority: normal | Keywords:
Component: | Architecture: Unknown/Multiple
Compiler | Difficulty: Moderate (less than a day)
Resolution: | Blocked By:
Operating System: | Related Tickets:
Unknown/Multiple |
Type of failure: |
None/Unknown |
Test Case: |
Blocking: |
----------------------------+----------------------------------------------
Comment (by goldfire):
In a conversation with several interested parties this morning, we came up
with the following leading proposals:
* Separate declaration, such as
{{{
type roles Map nominal representational
data Map a b = ...
}}}
Variants: Always use `type`? Or use `data` or `newtype` or `class`.
* Use a `where` clause:
{{{
data Map a b = ... where
roles Map nominal representational
}}}
The role annotation would appear in the existing `where` clause for
GADT-style declarations and for classes. A new `where` clause would be
permitted for non-GADT-style data/newtype declarations. Variant: drop the
redundant `Map`.
It was decided that using a `{-# PRAGMA #-}` is a bad idea because roles
are properly part of the language, not something outside it. Thus,
whatever we do will not be backwards-compatible, and that desideratum is
discarded. Though not brought up in the conversation, I would like to
propose an alternative syntax for an inline annotation:
{{{
data Map (a ::*, {nominal}) (b :: {representational}) = ...
}}}
Here, the role annotation is but in `{ }` along with a kind annotation.
They are, of course, optional. A role annotation would also be accepted
without a kind annotation -- the role would be distinguished by the `{ }`.
Variant: add the word `role` in the braces.
In any case, I would like to make a decision on this by early next week,
to give me time to implement the change before 9/14.
Thoughts?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8185#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list