We need to add role annotations for 7.8

David Menendez dave at zednenem.com
Fri Mar 28 20:27:00 UTC 2014

On Fri, Mar 28, 2014 at 3:56 PM, Richard Eisenberg <eir at cis.upenn.edu>wrote:

> - Edward and Mark have said that with a default of a nominal role "Nothing
> easy could just be easy." Yet, we accept the need for deriving Eq and Show
> without question. I think, if we ignore its current alienness, a role
> annotation is on a similar order -- a role annotation (in a world with a
> nominal default) would be granting new capabilities to users of a type,
> just like adding instances of classes.

Well, "deriving (Eq, Show)" is a bit less wordy than "type role Foo
representational representational". Although I guess you could just do
"type role Foo _ _ _".

On the other hand, telling people to add "type role Map nominal _" where it
matters is analogous to telling them to have an explicit export list when
they want to hide a type's constructors.

> - If you could use GND only where the constructors are available, then
> some valid current use of GND would break, I believe. It would mean that
> GND would be unable to coerce a (Map String Int) to a (Map String Age),
> because the constructor of Set is (rightly) not exported. This would have a
> direct runtime significance for some users -- their code would run slower.

One might attempt a compromise:

- types with explicit annotations always have the specified roles
- types with no explicit annotations but visible constructors have the
inferred roles
- types with no explicit annotations and no visible constructors have
nominal roles

Dave Menendez <dave at zednenem.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20140328/4f2d641e/attachment.html>

More information about the Libraries mailing list