{"action":"created","issue":{"url":"https://api.github.com/repos/elm-lang/core/issues/356","labels_url":"https://api.github.com/repos/elm-lang/core/issues/356/labels{/name}","comments_url":"https://api.github.com/repos/elm-lang/core/issues/356/comments","events_url":"https://api.github.com/repos/elm-lang/core/issues/356/events","html_url":"https://github.com/elm-lang/core/pull/356","id":101563968,"number":356,"title":"Add a new function: Signal.sendMessage : Message -> Task () ()","user":{"login":"rgrempel","id":64381,"avatar_url":"https://avatars.githubusercontent.com/u/64381?v=3","gravatar_id":"","url":"https://api.github.com/users/rgrempel","html_url":"https://github.com/rgrempel","followers_url":"https://api.github.com/users/rgrempel/followers","following_url":"https://api.github.com/users/rgrempel/following{/other_user}","gists_url":"https://api.github.com/users/rgrempel/gists{/gist_id}","starred_url":"https://api.github.com/users/rgrempel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgrempel/subscriptions","organizations_url":"https://api.github.com/users/rgrempel/orgs","repos_url":"https://api.github.com/users/rgrempel/repos","events_url":"https://api.github.com/users/rgrempel/events{/privacy}","received_events_url":"https://api.github.com/users/rgrempel/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-08-18T03:38:00Z","updated_at":"2015-08-25T16:44:08Z","closed_at":"2015-08-23T21:53:52Z","pull_request":{"url":"https://api.github.com/repos/elm-lang/core/pulls/356","html_url":"https://github.com/elm-lang/core/pull/356","diff_url":"https://github.com/elm-lang/core/pull/356.diff","patch_url":"https://github.com/elm-lang/core/pull/356.patch"},"body":"It would sometimes be convenient for third-party libraries to create functions that take a `Message` for a parameter, rather than an `Address` and an action. For instance, contrast these two signatures:\r\n\r\n```elm\r\nsendMessageWhenSomethingHappens : Address a -> a -> Task () ()\r\n\r\nsendMessageWhenSomethingHappens : Message -> Task () ()\r\n```\r\n\r\nAt the moment, the second signature is legal, but doesn't accomplish anything, because there is nothing which a third-party library can do with a `Message`. (Since `Message` is an opaque type and there are no functions which take `Message` as a parameter).\r\n\r\nI'm assuming that `Message` is an opaque type in part so that it is possible to provide a `Message` without exposing the `Address` (or, for that matter, the action) to the function. However, it is exactly that which would sometimes also be useful when it comes to third-party libraries.\r\n\r\nSo, what I am proposing with this pull request is to include a `sendMessage` function that would take the `Message` as a parameter and return a `Task` which, when executed, will send the `Message`. I would offer these further thoughts for your consideration:\r\n\r\n* Including the `sendMessage` function would still leave `Message` an opaque type -- one still would not be able to extract the `Address` or the action.\r\n\r\n* `Message` does not need to be parameterized, which has some advantages if the third-party library needs to put the messages in a `List`. That is, you could put several messages in a `List Message` even if the action types were different, which would not be possible for a `List (Address a, a)`.\r\n\r\n* The `sendMessage` function would simply return a `Task`, which would still need to be sent to a port to be executed. This is why the function does not rely on `Native.Signal.sendMessage`, which does some magic to actually perform the `Task`. (We can't rely on that here, because then `Signal.sendMessage` would not be a pure function).\r\n\r\n* It would not be possible to put this function in a signal-extra library as a preliminary step, because it cannot be implemented in a third-party library.\r\n\r\nIn the end, it just seems odd that the `Message` type can't be used by third-party libraries -- I would submit that a `Signal.sendMessage` would cure that oddity without creating any problems.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/elm-lang/core/issues/comments/134666600","html_url":"https://github.com/elm-lang/core/pull/356#issuecomment-134666600","issue_url":"https://api.github.com/repos/elm-lang/core/issues/356","id":134666600,"user":{"login":"rgrempel","id":64381,"avatar_url":"https://avatars.githubusercontent.com/u/64381?v=3","gravatar_id":"","url":"https://api.github.com/users/rgrempel","html_url":"https://github.com/rgrempel","followers_url":"https://api.github.com/users/rgrempel/followers","following_url":"https://api.github.com/users/rgrempel/following{/other_user}","gists_url":"https://api.github.com/users/rgrempel/gists{/gist_id}","starred_url":"https://api.github.com/users/rgrempel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rgrempel/subscriptions","organizations_url":"https://api.github.com/users/rgrempel/orgs","repos_url":"https://api.github.com/users/rgrempel/repos","events_url":"https://api.github.com/users/rgrempel/events{/privacy}","received_events_url":"https://api.github.com/users/rgrempel/received_events","type":"User","site_admin":false},"created_at":"2015-08-25T16:44:08Z","updated_at":"2015-08-25T16:44:08Z","body":"I should say that I do support the larger mailbox revamp, which would (as @mgold says) make this redundant."}}