{"action":"closed","issue":{"url":"https://api.github.com/repos/javaslang/javaslang/issues/488","labels_url":"https://api.github.com/repos/javaslang/javaslang/issues/488/labels{/name}","comments_url":"https://api.github.com/repos/javaslang/javaslang/issues/488/comments","events_url":"https://api.github.com/repos/javaslang/javaslang/issues/488/events","html_url":"https://github.com/javaslang/javaslang/issues/488","id":101979684,"number":488,"title":"Rethink flatMap et al.","user":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/javaslang/javaslang/labels/design/refactoring","name":"design/refactoring","color":"fbca04"}],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/javaslang/javaslang/milestones/18","html_url":"https://github.com/javaslang/javaslang/milestones/2.0.0","labels_url":"https://api.github.com/repos/javaslang/javaslang/milestones/18/labels","id":1091674,"number":18,"title":"2.0.0","description":"","creator":{"login":"danieldietrich","id":743833,"avatar_url":"https://avatars.githubusercontent.com/u/743833?v=3","gravatar_id":"","url":"https://api.github.com/users/danieldietrich","html_url":"https://github.com/danieldietrich","followers_url":"https://api.github.com/users/danieldietrich/followers","following_url":"https://api.github.com/users/danieldietrich/following{/other_user}","gists_url":"https://api.github.com/users/danieldietrich/gists{/gist_id}","starred_url":"https://api.github.com/users/danieldietrich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danieldietrich/subscriptions","organizations_url":"https://api.github.com/users/danieldietrich/orgs","repos_url":"https://api.github.com/users/danieldietrich/repos","events_url":"https://api.github.com/users/danieldietrich/events{/privacy}","received_events_url":"https://api.github.com/users/danieldietrich/received_events","type":"User","site_admin":false},"open_issues":25,"closed_issues":105,"state":"open","created_at":"2015-04-30T20:29:59Z","updated_at":"2015-08-24T01:48:16Z","due_on":null,"closed_at":null},"comments":20,"created_at":"2015-08-19T19:34:09Z","updated_at":"2015-08-24T01:48:16Z","closed_at":"2015-08-24T01:48:16Z","body":"The following is taken from a [pull request comment](https://github.com/javaslang/javaslang/pull/485#discussion_r37454043):\r\n\r\nWith `flatMap` we have a TODO in general but not here, with this pull-request.\r\n\r\nExample:\r\n\r\n```scala\r\nscala> \"123\".flatMap(Some(_))\r\nres0: String = 123\r\n\r\nscala> \"123\".flatMap(c => Some(c + 0))\r\nres1: scala.collection.immutable.IndexedSeq[Int] = Vector(49, 50, 51)\r\n\r\nscala> val words = Set(\"Patryk\", \"Ruslan\", \"Daniel\")\r\nwords: scala.collection.immutable.Set[String] = Set(Patryk, Ruslan, Daniel)\r\n\r\nscala> words flatMap (word => word.toSet)\r\nres2: scala.collection.immutable.Set[Char] = Set(e, s, n, y, t, u, a, i, l, P, r, R, k, D)\r\n\r\nscala> words flatten (word => word.toSet)\r\nres3: scala.collection.immutable.Set[Char] = Set(e, s, n, y, t, u, a, i, l, P, r, R, k, D)\r\n```\r\n\r\nOur flatMap works totally different. We need to check what is possible with Java, what makes sense and what is the expected behavior of flatMap. Maybe we need a Monad.unit(val) and Monoid.combine(m1, m2)...\r\n"}}