-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render type parameters as lambdas, and render typedefs more like term defs #1034
Comments
I've certainly never liked rendering parameters off to the right - they just ended up there because it was the easiest thing to implement. And it's become really ugly now that we also display kinds. My other idea had been to move back to something more form-like, with trees only where necessary (param kinds and field types), which would become feasible with #1043, which would free us from needing to represent each definition as a connected unit. But I'm increasingly keen on this approach instead. I really like the way that it unifies things with the term UI, by separating all parameter kinds in to their own subtree. There are still some important details I'd like to work out before I can say I'm 100% behind proceeding with this: Which character to use for the lambda?The proposed new node is not really equivalent to either our current But it now occurs to me that this problem is actually very closely related to how we used to confusingly use (I originally suggested How exactly should we render the tree?The obvious first draft would be to have lambdas above the definition name, and keep everything else as-is. But I think this would look a bit odd. We've discussed severing the links between the definition name and its two subtrees (again, helped by #1043). I'm in favour of this in general, but it's not clear quite how we should then connect the lambdas to the constructors. We played around with this a bit at our meetup two weeks ago but failed to come up with a compelling overall design. This might be affected by whether we display constructors similarly to pattern boxes. What action UX do we want?One option would be that we modify the kind tree in order to add parameters, with lambdas being read-only, but I'm not sure this would be intuitive. It would also mean "choose a parameter name" modals being necessary for certain kind edits. We could have an "add a parameter" action, which just adds a new parameter with kind Whatever we do, it's likely that some backend work will be required here. I think our API is slightly too tied to the idea of rendering each parameter kind separately. |
I think I'm on board with the idea of unifying the symbols for all bindings as |
This concern actually disappears if we render variable bindings separately from the nodes which they are now currently part of: Another advantage (and I think the original reason we'd discussed this) is that in eval mode, it would make it easier to see how a lambda is converted to a let in beta-reduction. * I don't think we actually have an issue for this? Perhaps it belongs in #54. |
Yes, I would like to find a way to visually unify bindings, while still respecting the important semantic differences. |
This is implemented in #1183. |
After some debate, we've decided that we would like to treat type parameters as being akin to term-level lambdas. Though they're not completely analogous, for our purposes, they're close enough, and the general consensus is that treating type parameters in this way will hopefully provide a bridge which leverages what students have learned about function parameters/lambdas to help them understand type parameters, in the sense that a type parameter binds a (variable) name to the scope in which the type's value constructors are defined.
To make the proposal more concrete, here's an example of how we might render a parameterized type in Primer's text representation, after adopting this proposal:
[Note here
type
is used asdata
is used in Haskell, and not as a type alias as would be the case in Haskell. Also, we're thinking that, as part of this change, we will drop the*
notation in the frontend and switch toType
, as then it's obvious that parameterized types take an argument of typeType
.]Also, we should then change how we render typedefs in tree representation to match how we render term defs — currently, with the type of the type on the left, and the constructors on the right. We also tentatively agreed that it would be good to render value constructors under the type lambdas, as expressions would be in function bodies, and from left to right with boxes around each constructor that mimic how we render value constructors in
match with
patterns in terms, in order to reinforce the association of pattern-matching to the value constructors of the corresponding type.Note that we don't expect this to require any major backend changes, as this is more or less a rendering decision, and not a change to the language's semantics. However, it should be reflected in Primer's terminology and documentation.
The text was updated successfully, but these errors were encountered: