-
Notifications
You must be signed in to change notification settings - Fork 1
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
[tracking] Better name generation #104
Comments
The prs hackworthltd/vonnegut#484 and hackworthltd/vonnegut#508 implement "first pass" and "additional step". We
We should think hard about what the default hints are. Currently they are just whatever seemed natural to @brprice when implementing it. These are not necessarily good pedagogically! We do not:
|
I think we've probably done as well as we're going to for initial user testing and demos. Removing this from the Demo project tracker. |
A fairly exhaustive list of existing naming conventions, potentially useful as inspiration: https://discourse.haskell.org/t/a-dictionary-of-single-letter-variable-names/10522/7. |
This is a tracking/planning issue for better name generation. A proposal is at https://github.com/hackworthltd/vonnegut/discussions/436. It was also discussed in our 2021-04-20 dev meeting : https://www.notion.so/hackworthltd/2021-04-20-Dev-meeting-a1d4f5d6a6034992b7a4b3cfe0f1e964
As a zeroth step, we should consider the questions below, and answer those which need early answers.
As a first pass, we will implement simple idris-style name hints, without worrying about automatic renaming (e.g. making it useful for let bindings). This will need to worry about uniqueness and shadowing etc.
A second pass will be making it more widely useful, especially for let bindings. This may be automatic renaming. Potentially we could do something clever with let bindings in particular, but that is not as widely applicable.
Automatic renaming is a bit worrying, as it could maybe be action-at-a-distance, which is unclear to the user. We may want to restrict it to
λi1 . ...
and wrap it inlet _ = ... in λi1 . ...
we probably shouldn't choose_ = i1
and renamei1
toj2
for instance).A third step is to do full fancy name generating described recursively by type.
Another step which can be ordered anytime after the first pass is to offer the user a list of automatically generated choices, rather than just choosing the best one. We should also have a manual rename action which will offer said list (as well as offering it when the variable is initially created).
Questions include:
Cons x1 xs1
and notCons x xs1
orCons x1 xs
.forall f. Functor f -> ...
, and have the namef
chosen automatically. Unfortunately this isn't really captured by the type/kind informationf : * -> *
, but by the fact thatf
is used as an argument toFunctor
, so something needs to change. [Two obvious differences: it is much more common to change the "constraints" later, so we need to worry about automatic renaming; it is simple to have multiple constraints and thus(?) ideas for names, how do we pick the "better" one?]let
s, but there we often get the info "soon": user creates alet
, then often the next step is to fill in the bound expr, giving us the type by inference]let h = ? in ...
, then seelet h = 1 in ...
and laterlet h = show 1 in ...
where the type ofh
is?
,Int
,String
....s
for lists. If we have longer names, then we may want to be smarter when generating names forList (Maybe (Pair Int Bool))
aslist_of_maybe_pair_int_bool
is a rather long (and useless?) variable name!The text was updated successfully, but these errors were encountered: