We need to add role annotations for 7.8
ekmett at gmail.com
Thu Mar 27 03:46:29 UTC 2014
Personally, looking at it 10 years on, having a nominal default would look
pretty terrible to me.
I'd be stuck annotating everything I write. Nothing easy could just be
The 10 years on crowd is a reasonable argument for a "real" type role
syntax, and it was indeed that argument that won me over, but if anything
the 10 year argument goes the other way for me on a nominal vs
On Wed, Mar 26, 2014 at 10:50 PM, Richard Eisenberg <eir at cis.upenn.edu>wrote:
> Not for more than a passing mention. Using the name of the module to
> control the default makes me unhappy (should choice of name be relevant in
> the correctness / interpretation of a program?). Other heuristics (presence
> of constrained functions) seem quite fragile. Of everything said so far, I
> think the closest suggestion is to use constrained datatypes (like `data
> Ord a => Set a = ...`), but that mis-appropriates datatype contexts (which
> are silly) into something new and different, and so I personally don't
> think it's really viable.
> Following Mark's idea of breaking this problem up into more manageable
> chunks, I would want us to think about two separate (and conflicting,
> often) users:
> 1. Users of today's Haskell who have to update their code.
> 2. Users of Haskell in 10 years.
> Would users in group (2) like these heuristics? I doubt it. I think users
> in group (2) would probably most like a default of nominal with role
> annotations (in some concrete syntax). But, users in group (1) would hate a
> nominal default, so we have a compromise.
> On Mar 26, 2014, at 11:40 AM, Casey McCann <cam at uptoisomorphism.net>
> > Were any rules considered along the lines of "Representational by
> > default if all the type's constructors are exported by a module not
> > named 'Internal', nominal by default otherwise"? Better would probably
> > include "exported by a module the package exposes" but that's
> > disgustingly non-local if it's even possible at all. The module name
> > thing is hacky to the extreme but at least it's a simple rule rather
> > than some obscure and opaque heuristics.
> > Anyway, the goal of something like that would be not so much "figure
> > out what it should be", since that's impossible, but more "default to
> > nominal if and only if there's clear indication the user is already
> > thinking about restricting how the type is used".
> > Not that I'm really even suggesting such a rule, just wondering if it
> > was discussed.
> > - C.
> > On Tue, Mar 25, 2014 at 7:23 PM, Richard Eisenberg <eir at cis.upenn.edu>
> >> Hi Mark,
> >> I appreciate your analysis in terms of classes of users -- I think that
> >> helpful for framing the discussion.
> >> About transitivity: I think we're in the clear here. Let's say package A
> >> exports types missing role annotations. If package B imports package A
> >> wants to have the full safety afforded by roles, that is no problem
> >> whatsoever. Package B has annotations on its types (which may use
> >> A's types) that may restrict certain parameters to be nominal, as
> >> appropriate. If package A had role annotations, it's quite possible that
> >> package B could omit some annotations (as role inference propagates
> >> roles), but there is no problem inherent in this. (Indeed, if package A
> >> annotations in the future, package B would have redundant, but harmless,
> >> annotations.) So, I disagree with Mark's "partially" below -- I think
> >> fully OK in this regard.
> >> About heuristics: we briefly considered some, though there's no
> >> documentation of this anywhere. Specifically, we thought about giving
> >> nominal roles to parameters used in class constraints. The problem is,
> >> the actual datatype definition, the constraints tend not to appear?
> >> we look around for other functions with constraints? That seems likely
> to be
> >> more confusing than helpful. Furthermore, I strongly don't like the
> idea of
> >> using heuristics to infer a feature such as this -- it can cause strange
> >> behavior and is hard to specify.
> >> Richard
> >> On Mar 25, 2014, at 11:09 AM, Mark Lentczner wrote:
> >> Thank you to everyone who has been helping me understand this issue in
> >> greater depth.
> >> tl;dr: As long as we don't expect any libraries beyond to core to
> >> I'm cool. This presumes that the extra safety isn't, in practice,
> >> on transitive adoption by libraries. It also implies that
> >> is the only possible default, and that there can be no migration from
> >> My approach to thinking about this is guided by thinking about
> supporting an
> >> eco-system with 1000s of libraries (hackage), a few dozen of which are
> >> heavily promoted (the platform), and a small set that are closely tied
> >> the compiler (the core). The availability, speed of release,
> motivation, and
> >> even skill of the the developers varies widely over that range.
> >> I also think about the various "stances" of different developers:
> >> End developer: makes use of libraries, but just builds apps
> >> Internal developer: makes libraries for internal use in a project
> >> Casual library writer: makes libraries, primarily for their own needs,
> >> distributed on hackage
> >> Popular library writer: actively maintains libraries which are widely
> >> Core library writer: maintainer of a core package that stays in lock
> >> with the compiler
> >> Then, I think about, for each of these, what is the effect on a new
> >> on them, their existing code, and future code? Does it affect them only
> >> they are using the feature? If they aren't using the feature? For
> >> writers, how does the feature affect clients? If a client wants to use a
> >> feature, under what conditions does the library need to do something?
> >> last issue of the "transitivity" the feature is often the biggest
> >> Given that... onto type roles:
> >> The default of representational is the only option, because a default of
> >> nominal would require far too many developers to have to update their
> >> I don't believe that we can ever migrate to nominal as default.
> >> The feature implies that any abstract data type that uses a type
> >> in certain ways needs annotate to get the full safety afforded now
> >> However, without annotation, the data type is still no worse off than
> it was
> >> before (there is added safety, but not perhaps relevant to the stand
> >> of the library writer). Further, this (pre-existing) non-safety isn't
> >> a huge concern. Making sure the docs take the tone that most developers
> >> to nothing, and when developers need to be concerned seems like an
> >> way to ensure the right outcome.
> >> A key question here is transitivity: Is it possible for module A to not
> >> annotate a type, and then have module B by a different author use the
> >> in A in another abstract type, that is annotated, and get the benefit.
> >> the answer is "partially". If the answer were "no", then use of the
> >> would be dependent on transitive adoption, and that is where the big
> >> on developers comes from.
> >> The degree to which we believe this "partially" is important: If we are
> >> willing to believe that the only library writers we care about doing
> >> are those in the core, then fine. In this case we shouldn't feel
> >> to suggest to library writers that they annotate, ever. I'm good with
> >> If the team here thinks otherwise, that we need to start a campaign to
> >> every library writer to eventually annotate, then I have deep
> >> I read the paper, and understand how the authors felt the syntax options
> >> were all less than perfect, and choose what they did. But that choice,
> >> perhaps unwittingly, the implication that it forces -XCPP on all
> >> except perhaps some of the core. This is because they all need to
> >> previous compilers. So, a one line annotation has turned into an ugly
> >> and perhaps added -XCPP where there was none, which is really
> >> (I, like many, consider it a defeat when one has to resort to -XCPP.)
> >> It seems to me that the paper didn't really consider less-perfect,
> >> solutions. It might have had significantly less impact on library
> >> were some heuristic (no constructors exported? has any type constraint
> >> the parameter? etc..) might have allowed most data types to go without
> >> annotation at the cost of a few (where nominal was incorrectly inferred)
> >> requiring immediate action. In this situation, a non-language feature
> >> (pragma or other device) might have been more palatable.
> >> Finally, on the choice of terms, nominal, representational, and phantom
> >> seem like clear, self-explanatory choices to me.
> >> - Mark
> >> _______________________________________________
> >> ghc-devs mailing list
> >> ghc-devs at haskell.org
> >> http://www.haskell.org/mailman/listinfo/ghc-devs
> >> _______________________________________________
> >> Libraries mailing list
> >> Libraries at haskell.org
> >> http://www.haskell.org/mailman/listinfo/libraries
> ghc-devs mailing list
> ghc-devs at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the ghc-devs