{"action":"created","issue":{"url":"https://api.github.com/repos/evancz/elm-effects/issues/25","labels_url":"https://api.github.com/repos/evancz/elm-effects/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/evancz/elm-effects/issues/25/comments","events_url":"https://api.github.com/repos/evancz/elm-effects/issues/25/events","html_url":"https://github.com/evancz/elm-effects/issues/25","id":108302871,"number":25,"title":"API question: Add a silentTask function?","user":{"login":"jvoigtlaender","id":5853832,"avatar_url":"https://avatars.githubusercontent.com/u/5853832?v=3","gravatar_id":"","url":"https://api.github.com/users/jvoigtlaender","html_url":"https://github.com/jvoigtlaender","followers_url":"https://api.github.com/users/jvoigtlaender/followers","following_url":"https://api.github.com/users/jvoigtlaender/following{/other_user}","gists_url":"https://api.github.com/users/jvoigtlaender/gists{/gist_id}","starred_url":"https://api.github.com/users/jvoigtlaender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvoigtlaender/subscriptions","organizations_url":"https://api.github.com/users/jvoigtlaender/orgs","repos_url":"https://api.github.com/users/jvoigtlaender/repos","events_url":"https://api.github.com/users/jvoigtlaender/events{/privacy}","received_events_url":"https://api.github.com/users/jvoigtlaender/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-25T10:44:27Z","updated_at":"2015-09-26T06:12:02Z","closed_at":null,"body":"There was a [thread on the mailing list](https://groups.google.com/d/msg/elm-discuss/siD4C9ZhaWo/rLvLmLYXDQAJ) that got me thinking:\r\n\r\nWhy should every task-turned-effects need to send a message to the address in `toTask` (or to the app's address in `start-app`)? There could be cases (like in the linked thread) where one wants to run a task just for its effect on the outside world, but not have it report back a value (or, actually, to ignore that value). But currently, running any task created via `Effects.toTask address (Effects.task task)` will definitely send something to `address`, which means that:\r\n* If there is no meaningful return value/action to send, the programmer has to artificially make up a `NoOp` action, possibly polluting their `Action` datatype (which might not yet contain, nor normally need, such a `NoOp` action).\r\n* Handling that `NoOp` sent is a spurious call of the app's `update` function (and then the `view` function as well), which it would be better to avoid if possible.\r\n\r\nSo here's my proposal:\r\n\r\nIn addition to\r\n```elm\r\nEffects.task : Task Never a -> Effects a\r\n```\r\nlet's add a function\r\n```elm\r\nEffects.silentTask : Task Never b -> Effects a\r\n```\r\nTo make it more difficult for the programmer to use that new function inappropriately/accidentally, one could also contemplate giving it the following more restricted type:\r\n```elm\r\nEffects.silentTask : Task Never () -> Effects a\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/evancz/elm-effects/issues/comments/143402404","html_url":"https://github.com/evancz/elm-effects/issues/25#issuecomment-143402404","issue_url":"https://api.github.com/repos/evancz/elm-effects/issues/25","id":143402404,"user":{"login":"jvoigtlaender","id":5853832,"avatar_url":"https://avatars.githubusercontent.com/u/5853832?v=3","gravatar_id":"","url":"https://api.github.com/users/jvoigtlaender","html_url":"https://github.com/jvoigtlaender","followers_url":"https://api.github.com/users/jvoigtlaender/followers","following_url":"https://api.github.com/users/jvoigtlaender/following{/other_user}","gists_url":"https://api.github.com/users/jvoigtlaender/gists{/gist_id}","starred_url":"https://api.github.com/users/jvoigtlaender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jvoigtlaender/subscriptions","organizations_url":"https://api.github.com/users/jvoigtlaender/orgs","repos_url":"https://api.github.com/users/jvoigtlaender/repos","events_url":"https://api.github.com/users/jvoigtlaender/events{/privacy}","received_events_url":"https://api.github.com/users/jvoigtlaender/received_events","type":"User","site_admin":false},"created_at":"2015-09-26T06:12:02Z","updated_at":"2015-09-26T06:12:02Z","body":"@evancz, I don't understand your concerns about error handling here. In particular with my second proposed type signature:\r\n```elm\r\nEffects.silentTask : Task Never () -> Effects a\r\n```\r\n\r\nThis won't release people from error handling at all. If they have a `Task x a` with some non-`Never` type for `x`, they will have to use something like `Task.toMaybe` or `Task.toResult` first. So far, this is the same story as with `Effects.task`. They are now at a `Task Never Something`. Only if that `Something` is `()` they would be able to use `Effects.silentTask` instead of `Effects.task`. So if there was indeed something erroneous about `Something`, they would have to explicitly map it away with `Task.map (always ())` or so.\r\n\r\nSo, this approach is *not* for \"things where you really don't want to do any error handling\". Not any more than `Effects.task` is (where you can also map away error information encoded in the type via `Task.map`). Even with `Effects.silentTask`, people will still have to explicitly say in their code \"this failed, but I don't care\" (if that is the case). Even with this function added (with the above type), people will *not* be able to easily say \"write to the database\" and have it fail silently if it fails. So my response to your questions is that I don't see how `Effects.silentTask : Task Never () -> Effects a` would interact badly with any task that can fail."}}