{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/12","labels_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/12/comments","events_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/12/events","html_url":"https://github.com/elm-lang/elm-plans/issues/12","id":96375220,"number":12,"title":"Proposal: Add Array, Dict, Set Literal Syntax","user":{"login":"TheSeamau5","id":3227869,"avatar_url":"https://avatars.githubusercontent.com/u/3227869?v=3","gravatar_id":"","url":"https://api.github.com/users/TheSeamau5","html_url":"https://github.com/TheSeamau5","followers_url":"https://api.github.com/users/TheSeamau5/followers","following_url":"https://api.github.com/users/TheSeamau5/following{/other_user}","gists_url":"https://api.github.com/users/TheSeamau5/gists{/gist_id}","starred_url":"https://api.github.com/users/TheSeamau5/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheSeamau5/subscriptions","organizations_url":"https://api.github.com/users/TheSeamau5/orgs","repos_url":"https://api.github.com/users/TheSeamau5/repos","events_url":"https://api.github.com/users/TheSeamau5/events{/privacy}","received_events_url":"https://api.github.com/users/TheSeamau5/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":21,"created_at":"2015-07-21T17:44:59Z","updated_at":"2015-07-22T11:45:35Z","closed_at":null,"body":"Inspired by [Clojure's collection literals](http://clojure.org/reader), I propose to add support for Array, Dict, and Set literals (analogous to List syntax).\r\n\r\n#### Proposed syntax\r\n\r\n**Array**\r\n```elm\r\narray = \r\n  #[1, 2, 3]\r\n```\r\n\r\nRationale: Looks like a list but with a hash sign.\r\n\r\n**Dict**\r\n```elm\r\ndict = \r\n  #{ \"key1\" : \"value1\"\r\n   , \"key2\" : \"value2\"\r\n   , \"key3\" : \"value3\"\r\n   }\r\n```\r\n\r\nRationale: Looks like Json. In spirit, Dicts and Json serve the same purpose--to store key-value data.\r\n\r\n**Set**\r\n```elm\r\nset = \r\n  #{1, 1, 2, 3, 2}\r\n```\r\n\r\nRationale: While we're at it, why not? I mean... Clojure does it.\r\n\r\n\r\nIn all cases, the main goal of the syntax is to encourage the usage of these datastructures, which have advantages that linked lists don't. Arrays have fast access, setting, and efficient appending to the end. Dicts are perfect for storing key-value data. Sets guarantee that there are no duplicates (therefore, no need to filter out all duplicates from a list).\r\n\r\nCurrently, if you want to write a DSL in Elm (like elm-html), lists and records are your only tools. The downside of this is that lists may not be the optimal data structure for your DSL.\r\n\r\nFor example, here is how elm-html would look with arrays and dicts\r\n\r\n```elm\r\ndiv \r\n  #[ style #{ \"position\" : \"absolute\" , \"color\" : \"red\" } \r\n   , id \"containerDiv\" \r\n   ]\r\n  #[ ul #[]\r\n      #[ li #[] #[text \"Hello\"]\r\n       , li #[] #[text \"World\"]\r\n       ]  \r\n   ] \r\n```"},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/comments/123686672","html_url":"https://github.com/elm-lang/elm-plans/issues/12#issuecomment-123686672","issue_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/12","id":123686672,"user":{"login":"mgold","id":1191970,"avatar_url":"https://avatars.githubusercontent.com/u/1191970?v=3","gravatar_id":"","url":"https://api.github.com/users/mgold","html_url":"https://github.com/mgold","followers_url":"https://api.github.com/users/mgold/followers","following_url":"https://api.github.com/users/mgold/following{/other_user}","gists_url":"https://api.github.com/users/mgold/gists{/gist_id}","starred_url":"https://api.github.com/users/mgold/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgold/subscriptions","organizations_url":"https://api.github.com/users/mgold/orgs","repos_url":"https://api.github.com/users/mgold/repos","events_url":"https://api.github.com/users/mgold/events{/privacy}","received_events_url":"https://api.github.com/users/mgold/received_events","type":"User","site_admin":false},"created_at":"2015-07-22T11:45:35Z","updated_at":"2015-07-22T11:45:35Z","body":"Time to benchmark, then."}}