{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/979","labels_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/979/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/979/comments","events_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/979/events","html_url":"https://github.com/elm-lang/elm-compiler/issues/979","id":93074550,"number":979,"title":"Proposal: Commas Work Like Semicolons","user":{"login":"rtfeldman","id":1094080,"avatar_url":"https://avatars.githubusercontent.com/u/1094080?v=3","gravatar_id":"","url":"https://api.github.com/users/rtfeldman","html_url":"https://github.com/rtfeldman","followers_url":"https://api.github.com/users/rtfeldman/followers","following_url":"https://api.github.com/users/rtfeldman/following{/other_user}","gists_url":"https://api.github.com/users/rtfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/rtfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtfeldman/subscriptions","organizations_url":"https://api.github.com/users/rtfeldman/orgs","repos_url":"https://api.github.com/users/rtfeldman/repos","events_url":"https://api.github.com/users/rtfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/rtfeldman/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":23,"created_at":"2015-07-05T04:12:04Z","updated_at":"2015-07-13T15:17:21Z","closed_at":"2015-07-13T15:17:21Z","body":"This is based on @Apanatshka's [comment on the Optional Commas proposal](https://github.com/elm-lang/elm-compiler/issues/978#issuecomment-118437011). It essentially says that commas in Elm should work like semicolons do in other languages, such as in Ruby or in Haskell's `do` notation—that is, they are used as a separator only in single-line cases, and in multiline cases newlines are the separator instead. This proposal is simpler but less backwards-compatible than optional commas.\r\n\r\nHere is TodoMVC with and without the proposed change:\r\n\r\n[Current TodoMVC](https://gist.github.com/rtfeldman/4682d081daab74ec185f)\r\n[TodoMVC with proposed change](https://gist.github.com/rtfeldman/26fe87e2908e03e2322c)\r\n\r\n## Proposed Implementation\r\n\r\n**1.** Multiline terms are delimited by newlines **instead of** commas. This is a breaking change.\r\n\r\nExamples:\r\n\r\n```elm\r\n-- equivalent to:\r\n-- { x = 1, y = 5 }\r\n{\r\n  x = 1\r\n  y = 5\r\n}\r\n\r\n-- equivalent to:\r\n-- [label [class \"login-field\"] [text \"username:\"], input [name \"username\"] [], button [] [text \"Submit\"]]\r\n[\r\n  label [class \"login-field\"] [text \"username:\"]\r\n  input [name \"username\"] []\r\n  button [] [text \"Submit\"]\r\n]\r\n\r\n-- equivalent to:\r\n-- (x, y, z)\r\n(\r\n  x\r\n  y\r\n  z\r\n)\r\n\r\n-- equivalent to:\r\n-- type alias Bounds = { width : Int, height : Int }\r\ntype alias Bounds = {\r\n  width : Int\r\n  height : Int\r\n}\r\n\r\n-- equivalent to:\r\n-- module Foo (bar, baz, qux) where\r\nmodule Foo (\r\n    bar\r\n    baz\r\n    qux\r\n  ) where\r\n\r\n-- equivalent to { point | x <- point.x + 1, y <- point.y + 1 }\r\n{ point | x <- point.x + 1\r\n          y <- point.y + 1 }\r\n```\r\n\r\n**2.** Commas become delimiters for single-line terms only.\r\n\r\nComma-delimited terms that begin and end on a single line work as they currently do. Examples:\r\n\r\n```elm\r\n[firstThing, secondThing, thirdThing]\r\n\r\n{ x = 1, y = 5 }\r\n\r\n(x, y, z)\r\n\r\ntype alias Bounds = { width : Int, height : Int }\r\n\r\nmodule Foo (bar, baz, qux) where\r\n```\r\n\r\n**3.** To remove ambiguity, function application across multiple lines now requires indentation. This is a breaking change.\r\n\r\n```elm\r\n-- still compiles\r\nfoo 1 2 3\r\n\r\n-- still compiles\r\nfoo\r\n  1 2 3\r\n\r\n-- no longer compiles\r\nfoo\r\n1 2 3\r\n```\r\n\r\n**4.** The preceding rule implies that all elements in a multiline term must be at the same indentation level.\r\n\r\nFor example:\r\n\r\n```elm\r\n-- still compiles\r\n[\r\n  label [class \"login-field\"] [text \"username:\"]\r\n  input [name \"username\"] []\r\n  button [] [text \"Submit\"]\r\n]\r\n\r\n-- does not compile, because this is attempting to pass 3 extra arguments to `input`\r\n-- (namely `button`, `[]`, and `[text \"Submit\"]`)\r\n[\r\n  label [class \"login-field\"] [text \"username:\"]\r\n  input [name \"username\"] []\r\n    button [] [text \"Submit\"]\r\n]\r\n\r\n-- compiles to the equivalent of (3, 4, 5)\r\n(\r\n  3\r\n  4\r\n  5\r\n)\r\n\r\n-- does not compile, because this is attempting to call 3 as if it were a function,\r\n-- passing 4 as an argument. \r\n(\r\n  3\r\n    4\r\n  5\r\n)\r\n```\r\n\r\n**5.** Commas may not be used to delimit multiline terms.\r\n\r\n```elm\r\n-- compiles\r\n[foo, bar, baz]\r\n\r\n-- compiles\r\n[\r\n  foo\r\n  bar\r\n  baz\r\n]\r\n\r\n-- does not compile\r\n[\r\n  foo, bar\r\n  baz\r\n]\r\n```\r\n\r\n## Motivation\r\nTo avoid duplication, please see the original [Optional Commas proposal](https://github.com/elm-lang/elm-compiler/issues/978) for motivation. All the same motivating reasons apply here as well."},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/comments/120964063","html_url":"https://github.com/elm-lang/elm-compiler/issues/979#issuecomment-120964063","issue_url":"https://api.github.com/repos/elm-lang/elm-compiler/issues/979","id":120964063,"user":{"login":"rtfeldman","id":1094080,"avatar_url":"https://avatars.githubusercontent.com/u/1094080?v=3","gravatar_id":"","url":"https://api.github.com/users/rtfeldman","html_url":"https://github.com/rtfeldman","followers_url":"https://api.github.com/users/rtfeldman/followers","following_url":"https://api.github.com/users/rtfeldman/following{/other_user}","gists_url":"https://api.github.com/users/rtfeldman/gists{/gist_id}","starred_url":"https://api.github.com/users/rtfeldman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtfeldman/subscriptions","organizations_url":"https://api.github.com/users/rtfeldman/orgs","repos_url":"https://api.github.com/users/rtfeldman/repos","events_url":"https://api.github.com/users/rtfeldman/events{/privacy}","received_events_url":"https://api.github.com/users/rtfeldman/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T15:17:21Z","updated_at":"2015-07-13T15:17:21Z","body":":+1: "}}