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

Adding multiple fields to a record #325

Closed
nphollon opened this Issue Aug 2, 2015 · 1 comment

Comments

Projects
None yet
1 participant
@nphollon
Contributor

nphollon commented Aug 2, 2015

Elm allows us to update multiple fields at once on a record. By analogy, it feels very natural to add multiple fields using this notation:

addTwoFields record = { record | b = 4, c = 7 }

But it leads to a syntax error:

Parse error at (line 8, column 39):
unexpected ","
expecting digit, ".", "e", "E", whitespace, a newline, "-", basic term (4, x, 'c', etc.), infix operator or closing bracket '}'

The alternative I have found is rather verbose:

addTwoFields record = 
  let record' = { record | b = 4 }
  in { record' | c = 7 }

@nphollon nphollon closed this Aug 2, 2015

@nphollon

This comment has been minimized.

Show comment
Hide comment
@nphollon

nphollon Aug 2, 2015

Contributor

My apologies, this issue looks like it belongs in elm-compiler, not in core

Contributor

nphollon commented Aug 2, 2015

My apologies, this issue looks like it belongs in elm-compiler, not in core

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment