Closed robinheghan closed 1 year ago
Here are my humble opinions:
case
indentationI would rather keep on using indentation than the pipe operator that was previously used only for sum types. Indentation is what makes code readable by indicating grouping without noise in the code that all these pipes and parentheses would introduce.
In sum types the pipe character |
is a bit like a logical OR between types. Beginning with one would be a logical nonsense.
end
or another delimiter for case
As you said using end
with case
whereas Gren does not use it elsewhere would be weird and once again add more noise in the code.
Thank you for your input!
Indentation is what makes code readable
I don't disagree with this principle, however I've frequently had the experience that I'm, for one reason or another, missing a space in a crucial place so that (a) my code doesn't compile and (b) my code isn't formatted by the formatter. I'd much rather rely on gren format
for making the code nice, than to have to make the code read nicely for it to compile at all.
Beginning with one would be a logical nonsense.
I see your point. Allowing a leading pipe makes it easier to move branches around while refactoring, though.
I see your points too. But remember that code is read much more often than it is written :wink:
actually are like adopting the F# syntax
Nah. The proposals are trying to fix what I consider to be problems with the syntax inherited from Elm, and both OCaml (not F#), Haskell and PureScript are natural to draw inspiration from.
Is Gren moving towards something like Elmish + Fable?
Not sure what that means 😅 But no, we have no plans to adopt more features from Ocaml/F#/Haskell than what is currently proposed.
Rejecting this proposal.
I believe the whitespace sensitivity can be improved without any change in syntax, and the other points not directly related to whitespace sensitivity aren't important enough to change.
In brief, this proposes to change the case..of syntax from
To
This has two benefits:
Finally, I’m also proposing that it’s ok for custom type definitions to begin with a pipe before the first constructor, as is the case below
Alternatives
One could also choose to use a delimiter to determine when a case expression ends, like in the example below
The benefit of this is that you wouldn’t require parens for nested case expressions, or delimiters to signal the start of a branch. The counter argument is that Gren doesn’t typically rely on delimiters to limit the scope of expressions or statements, so it feels a little out of place. Also, depending on the delimiter, it could collide with valid variable names.