{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/3","labels_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/3/comments","events_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/3/events","html_url":"https://github.com/elm-lang/elm-plans/issues/3","id":94505735,"number":3,"title":"Proposal: Remove multi-way `if`","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":[{"url":"https://api.github.com/repos/elm-lang/elm-plans/labels/proposal","name":"proposal","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":22,"created_at":"2015-07-11T20:33:17Z","updated_at":"2015-08-10T21:13:36Z","closed_at":null,"body":"## Proposed Change\r\n\r\nRemove the multi-way `if` syntax.\r\n\r\nCurrently the Elm Syntax docs include [this example](http://elm-lang.org/docs/syntax#conditionals):\r\n\r\n```elm\r\nif | key == 40 -> n+1\r\n   | key == 38 -> n-1\r\n   | otherwise -> n\r\n```\r\n\r\nThis would no longer work. Instead, this example would be rewritten to the following:\r\n\r\n```elm\r\nif key == 40 then\r\n    n + 1\r\nelse if key == 38 then\r\n    n - 1\r\nelse\r\n    n\r\n```\r\n\r\nThis would be a breaking compiler change.\r\n\r\n## Motivation\r\n\r\nThe multi-way `if` syntax has these problems:\r\n\r\n1. It [can currently lead to non-exhaustive matches](https://github.com/elm-lang/elm-compiler/issues/385).\r\n2. It adds complexity to the compiler and learning curve to new users, in exchange for conciseness but no additional capabilities.\r\n3. Expanding from a normal `if`/`else` to a multi-way `if` requires rewriting the entire expression, and failing to do so when a third case arises leads to stylistic inconsistencies across the code base.\r\n4. It is a rarely-used feature in a language with pattern matching."},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/comments/129607683","html_url":"https://github.com/elm-lang/elm-plans/issues/3#issuecomment-129607683","issue_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/3","id":129607683,"user":{"login":"evancz","id":1658058,"avatar_url":"https://avatars.githubusercontent.com/u/1658058?v=3","gravatar_id":"","url":"https://api.github.com/users/evancz","html_url":"https://github.com/evancz","followers_url":"https://api.github.com/users/evancz/followers","following_url":"https://api.github.com/users/evancz/following{/other_user}","gists_url":"https://api.github.com/users/evancz/gists{/gist_id}","starred_url":"https://api.github.com/users/evancz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evancz/subscriptions","organizations_url":"https://api.github.com/users/evancz/orgs","repos_url":"https://api.github.com/users/evancz/repos","events_url":"https://api.github.com/users/evancz/events{/privacy}","received_events_url":"https://api.github.com/users/evancz/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T21:13:36Z","updated_at":"2015-08-10T21:13:36Z","body":"@bbugh, thanks for you perspective! The style you recommend was the one I initially showed to @rtfeldman that initiated this issue. That style is what I was planning to recommend if this feature was removed for pretty much exactly the reasons you outline.\r\n\r\nAlso, the one you theorized is \"more elm like\", not in my code I hope, that looks awful to me! :)"}}