{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/7","labels_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/7/comments","events_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/7/events","html_url":"https://github.com/elm-lang/elm-plans/issues/7","id":94946926,"number":7,"title":"Proposal: Mailbox Revamp","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},"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":23,"created_at":"2015-07-14T13:37:58Z","updated_at":"2015-07-22T19:46:16Z","closed_at":null,"body":"This proposal attempts to codify the ideas from [this thread](https://groups.google.com/d/msg/elm-discuss/J5dBfWJoLoQ/ZPPk-D625eYJ). This would be a breaking change to core, but no change to the language itself.\r\n\r\n## Motivation\r\nAs is clear from reading the thread, \"mailbox\" is has failed as a metaphor. A few other issues with [the API](http://package.elm-lang.org/packages/elm-lang/core/2.1.0/Signal#mailboxes):\r\n\r\n* The `Address` type is completely opaque, and hard to gain intuition about. However, it's really the only thing tying the API together.\r\n* That is, there's `message` to create a `Message`, and `send` to create a `Task`, but neither of these seem to fit very well.\r\n* `forwardTo : Address b -> (a -> b) -> Address a` is really confusing. It took me several tries to get my head around it. The average JS or Ruby dev is not comfortable with the phrase \"contravariant functor\".\r\n\r\n## Proposed Change\r\nI'm not 100% on the names yet; please focus on the types.\r\n\r\n```elm\r\ntype alias Dispatcher a = \r\n    { dispatch : a -> Message -- the big change\r\n    , signal : Signal a \r\n    }\r\n\r\ndispatcher : a -> Dispatcher a -- just renamed mailbox\r\nsend : Message -> Task x ()\r\n```\r\n\r\nLet's start by what's _not_ in the API. There's no explicit `message` function aside from `dispatch` itself. This encourages people to use messages, which are safer (they can't perform arbitrary actions e.g. Http). And `forwardTo` drops out entirely, replaced by dirt standard function composition.\r\n\r\nFinally, `send` takes a `Message`. Currently, `send` and `message` are both ` Address a -> a -> ...`, implying parity. Now, it's clearly extra work to use a task. This implies (correctly) that a message is the primary type at play here. The exposed function plays very well with Graphics.Input, every function in which takes either a `Message` or an `(a -> Message)`.\r\n\r\n## Next Steps\r\nThis proposal had support from both newcomers and regulars on the thread, though you're welcome to oppose here. As mentioned above, I think the biggest remaining hurdle is to find the right names. I think implementation will be fairly straightforward, although it's important to get the docs right."},"comment":{"url":"https://api.github.com/repos/elm-lang/elm-plans/issues/comments/123841435","html_url":"https://github.com/elm-lang/elm-plans/issues/7#issuecomment-123841435","issue_url":"https://api.github.com/repos/elm-lang/elm-plans/issues/7","id":123841435,"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-07-22T19:46:16Z","updated_at":"2015-07-22T19:46:16Z","body":"Time and additional exploration. I am doing some work that led to an alternate way to achieve the same goals. I am not ready to share that work yet."}}