-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Allow omitting 'in' in chained bindings #260
Comments
Partially referencing the discussion in dhall-lang/dhall-haskell#662 and continuing from there: I have to say that this proposal is intriguing, because:
So I guess I consider this a good idea, but there is a big downside we should carefully consider: this is going to break basically all the existing expressions |
From what I gather, this won't break expressions. I am not sure if the reshuffling is a good idea. It certainly complicates implementations as they now have to track dependencies between the bindings. The top-to-bottom order is fool-proof both for readers and implementation. |
@vapourismo oh sorry you're right, this won't break anything 👍 Re: reshuffling: I wasn't talking about implementations doing it, but about programmers (me in this case) refactoring code. Example: Let's say you have this program: let b = 2
in b Now if I want to add an let a = 1
in let b = 2
in b However, with your proposal, I could just add a line before that without changing anything else: let a = 1
let b = 2
in b and this is nice 👍 |
Ah, I misunderstood. |
I'm still weakly opposed to this, but I must relent if @f-f supports it 🙂 Continuing the discussion from dhall-lang/dhall-haskell#662, what I mean by "significant" code compression is that it changes the "code complexity" (i.e. Big-O code size). This is only a constant-factor improvement, which is why I'm reluctant to add it given that it introduces yet another way to express the same idea. Probably the easiest way to explain "code complexity" is by comparison to the Similarly, any feature which removes unnecessary type annotations (like The reason I try to minimize having multiple ways to express the same thing is due to my experiences teaching Haskell. I discovered that many Haskell learners were routinely surprised by many basic equivalences like:
Every time you add such a new equivalence the learner typically asks why the language has two ways to express the same idea. In particular, they often ask if one version behaves differently. For example, in the context of
Whereas if you express expressions as nested |
I agree with @Gabriel439 here and continue thinking that records could be an alternative although you have to group the variables in dependency levels, making it clear:
In case of choose remove the
|
Thinking in the record alternative, it is clear that it would need record matching as suggested by @ocharles in #226 (comment)
Is not useful to know that the variable definition must be in a block that is above the current one? |
@Gabriel439 It's funny that you list specifically these two questions from learners. They are exactly two of the ones that I had when starting with Dhall. In fact, I initially believed I've made the observation that the current status quo of formating bindings is very annoying to a beginner. I eventually forfeited to it. Maybe this can be improved. @jneira |
@vapourismo mmm, i meant that you can use several records for that, grouping the variables. A runnable example would be:
You save three
Obviously you start to save chars only from 10/15 vars. |
To be honest, I don’t see any benefit at all, apart from confusion, especially concerning the very important question whether |
In the interest of avoiding hostility I'm going to ask that people refrain from using GitHub reactions (both positive and negative) to weigh in on a divided issue like this one since they can easily be misconstrued and turn this into a popularity contest instead of a technical discussion. GitHub reactions also don't factor into whether or not to accept the proposal. Proposals are approved according to the rules outlined here: To summarize those rules inline here:
I've already indicated that I plan to vote against the proposal, but if the proposal is accepted I will still embrace it wholeheartedly. The main thing we need is an explicit vote from @f-f. The more quickly we make a decision, in either direction, the more likely we can avoid conflict. No matter which way we decide there will be people unhappy with the outcome, but agreeing to our shared rules and embracing their outcome is vital to sustaining the project's long-term health. |
That response seems like the sort of thing that might end up in a code of conduct. I don't want to derail the issue, but maybe keep that response in the back of your mind until the time comes. |
Cool, thank you for considering. |
It looks to me that this point about "making Recapping the ideas around so far:
While we try to improve the experience in some aspect we should make sure not to make some other aspect worse - in particular the point about having "one way to do things" is really important to keep in mind (the danger is to mess up things like beginners experience). I consider this "almost another way to do things": it technically is, but it doesn't feel like it. As Gabriel recapped above, in the event of a tie on a proposal then it goes through. So since there's no unanimous consensus on this (unlike there was for other language changes, like #138 or #227), I propose we should:
(@Gabriel439 this effectively counts as a negative vote) |
For me it's mostly aesthetic and most minor of pains having to add an I would prefer what was proposed in #226 i.e.
I am starting to take up the habit of binding all imports at the top of the file due to the freeze hashes wrecking havock on diffs 😄 so less |
#226's proposal (for It may be productive to come up with a concrete set of proposals and work through them one at a time, so we're all clear which are rejected (and why), and which are still on the table. |
Alright, then I'll change my vote to approve this, but I would still prefer to require a
|
@Gabriel439: So to clarify the style would be:
correct? |
@FintanH: Correct Also, how the Haskell implementation would format things is technically outside of the scope of this proposal since it's not a standardized behavior, but I assume that the Haskell formatter would now format the expressions like this: let foo = 1
let bar = 2
in foo + bar In other words, one space after |
And what about use commas (or another single char) to separate them (as suggested in #260 (comment))?
The formatting could be
|
@jneira: Yeah, I would be okay with commas, too, because it looks similar to defining the fields of a record and looks nicer when defined on one line @vapourismo: What do you think about using |
@Gabriel439 @jneira using commas would not solve the problem of shuffling bindings around Example: if I have let foo = 1
, bar = 2
in foo + bar I cannot just cut the line with |
Ya @f-f has a strong point there 👍 |
If dhall were to allow leading commas, we would avoid the shuffling problem and could also fix #66 with the same convention let
, foo = 1
, bar = 2
in foo + bar colors = [
, "Red"
, "Blue"
, "Green"
] |
I prefer the It is worth noting that the perceived grammar would be simpler with commas, as they are also used in records to seperate |
Mmm, but only the first one, right? Usually you have more than two vars and i am not sure if being able to move a var to the top without retyping is better than the save in chars and the more clear aspect (that one is totally subjective of course) let prelude = /path/to/prelude
, types = /path/to/types
, var1 = value1
, var2 = value2
... And it is no very frequent to move other binding at the top to replace Anyway i dont want to extend the discussion further and fall in the wadler's law so simply go ahead with it 😄 |
Yeah, I think we should just go with leading |
Fixes #260 In other words, this is now legal: ```haskell let x = 1 let y = 2 in x + y ```
Fixes #260 In other words, this is now legal: ```haskell let x = 1 let y = 2 in x + y ```
In my head this is a purely cosmetic change.
It should not change the validity of programs that are currently valid.
What was previously written as
can now be written like
This effectively makes
in
terminate alet
-chain.PR: dhall-lang/dhall-haskell#662
Related: #226
The text was updated successfully, but these errors were encountered: