{"action":"created","issue":{"url":"https://api.github.com/repos/arrow-kt/arrow/issues/1553","repository_url":"https://api.github.com/repos/arrow-kt/arrow","labels_url":"https://api.github.com/repos/arrow-kt/arrow/issues/1553/labels{/name}","comments_url":"https://api.github.com/repos/arrow-kt/arrow/issues/1553/comments","events_url":"https://api.github.com/repos/arrow-kt/arrow/issues/1553/events","html_url":"https://github.com/arrow-kt/arrow/issues/1553","id":482906640,"node_id":"MDU6SXNzdWU0ODI5MDY2NDA=","number":1553,"title":"Monad Comprehensions without coroutine","user":{"login":"kalistace","id":1071941,"node_id":"MDQ6VXNlcjEwNzE5NDE=","avatar_url":"https://avatars1.githubusercontent.com/u/1071941?v=4","gravatar_id":"","url":"https://api.github.com/users/kalistace","html_url":"https://github.com/kalistace","followers_url":"https://api.github.com/users/kalistace/followers","following_url":"https://api.github.com/users/kalistace/following{/other_user}","gists_url":"https://api.github.com/users/kalistace/gists{/gist_id}","starred_url":"https://api.github.com/users/kalistace/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kalistace/subscriptions","organizations_url":"https://api.github.com/users/kalistace/orgs","repos_url":"https://api.github.com/users/kalistace/repos","events_url":"https://api.github.com/users/kalistace/events{/privacy}","received_events_url":"https://api.github.com/users/kalistace/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2019-08-20T14:45:37Z","updated_at":"2019-08-20T18:16:51Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nAs far as I understand, each binding step in a monad comprehension will leverage kotkin suspended function feature, this great for IO, or very intensive task, but what if I just want to use it as syntactic sugar to avoid nested flatmap structures ? For instance to compute simple Task.\r\n\r\nTo illustrate, let's take an snippet from the documentation :  \r\n```\r\nbinding {\r\n  val a = Try { \"3\".toInt() }.bind()\r\n  val b = Try { \"4\".toInt() }.bind()\r\n  val c = Try { \"5\".toInt() }.bind()\r\n  a + b + c\r\n}\r\n// Success(value=12)\r\n```\r\nIn the example, am I correct to think the runtime overhead of maintaining suspended functions will be greater than what it brings me ?\r\n\r\nAlthough, this is an overly simplified example, in real applications such computation does happen, top of head, for instance to validate user input before sending it to a service or a IO function.\r\n\r\nIs there a way to have binding step running normally on the main thread ? The current workaround I can think of is to use nested flatmaps but it quickly gets unreadable.\r\n\r\nThanks"},"comment":{"url":"https://api.github.com/repos/arrow-kt/arrow/issues/comments/523134689","html_url":"https://github.com/arrow-kt/arrow/issues/1553#issuecomment-523134689","issue_url":"https://api.github.com/repos/arrow-kt/arrow/issues/1553","id":523134689,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMzEzNDY4OQ==","user":{"login":"raulraja","id":456796,"node_id":"MDQ6VXNlcjQ1Njc5Ng==","avatar_url":"https://avatars3.githubusercontent.com/u/456796?v=4","gravatar_id":"","url":"https://api.github.com/users/raulraja","html_url":"https://github.com/raulraja","followers_url":"https://api.github.com/users/raulraja/followers","following_url":"https://api.github.com/users/raulraja/following{/other_user}","gists_url":"https://api.github.com/users/raulraja/gists{/gist_id}","starred_url":"https://api.github.com/users/raulraja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/raulraja/subscriptions","organizations_url":"https://api.github.com/users/raulraja/orgs","repos_url":"https://api.github.com/users/raulraja/repos","events_url":"https://api.github.com/users/raulraja/events{/privacy}","received_events_url":"https://api.github.com/users/raulraja/received_events","type":"User","site_admin":false},"created_at":"2019-08-20T18:16:51Z","updated_at":"2019-08-20T18:16:51Z","author_association":"MEMBER","body":"@kalistace we agree and this is coming up for all data types that provide Monad around October https://github.com/47deg/arrow-meta-prototype/blob/rr-typeclasses-plugin/compiler-plugin/src/main/kotlin/arrow/meta/comprehensions/ComprehensionsPlugin.kt we are already working in a prototype that rewrites binds as flatMap because that is leaner than suspension. It will still use suspension for the code as it is today but will rewrite it to a nested flatMap "}}
{"actor":{"display_login":"raulraja"}}