{"action":"opened","issue":{"url":"https://api.github.com/repos/danneu/elm-ordered-dict/issues/1","repository_url":"https://api.github.com/repos/danneu/elm-ordered-dict","labels_url":"https://api.github.com/repos/danneu/elm-ordered-dict/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/danneu/elm-ordered-dict/issues/1/comments","events_url":"https://api.github.com/repos/danneu/elm-ordered-dict/issues/1/events","html_url":"https://github.com/danneu/elm-ordered-dict/issues/1","id":186617921,"number":1,"title":"Bug with insert","user":{"login":"chancyk","id":1731217,"avatar_url":"https://avatars.githubusercontent.com/u/1731217?v=3","gravatar_id":"","url":"https://api.github.com/users/chancyk","html_url":"https://github.com/chancyk","followers_url":"https://api.github.com/users/chancyk/followers","following_url":"https://api.github.com/users/chancyk/following{/other_user}","gists_url":"https://api.github.com/users/chancyk/gists{/gist_id}","starred_url":"https://api.github.com/users/chancyk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chancyk/subscriptions","organizations_url":"https://api.github.com/users/chancyk/orgs","repos_url":"https://api.github.com/users/chancyk/repos","events_url":"https://api.github.com/users/chancyk/events{/privacy}","received_events_url":"https://api.github.com/users/chancyk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-01T19:01:01Z","updated_at":"2016-11-01T19:01:01Z","closed_at":null,"body":"OrdereredDict.insert is just returning the dict when the key already exists, as seen below:\r\n\r\n```elm\r\ninsert : comparable -> v -> OrderedDict comparable v -> OrderedDict comparable v\r\ninsert k v dict =\r\n  if Dict.member k dict.items then\r\n    dict\r\n  else\r\n    { dict | items = Dict.insert k (Array.length dict.indexes) dict.items\r\n           , indexes = Array.push (Just v) dict.indexes\r\n    }\r\n```\r\n\r\nI think it should be something like this instead:\r\n\r\n```elm\r\nlet\r\n    index = Dict.get k dict.items\r\nin\r\n    case index of\r\n        Just idx ->\r\n            { dict | indexes = Array.set idx (Just v) dict.indexes }\r\n        Nothing ->\r\n            dict\r\n```"}}
{"actor":{"display_login":"chancyk"}}