{"action":"created","issue":{"url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/20","labels_url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/20/comments","events_url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/20/events","html_url":"https://github.com/stuartervine/OCTotallyLazy/issues/20","id":59595447,"number":20,"title":"Map, flatMap, and flatten should work on a single layer only","user":{"login":"esorf","id":1261725,"avatar_url":"https://avatars.githubusercontent.com/u/1261725?v=3","gravatar_id":"","url":"https://api.github.com/users/esorf","html_url":"https://github.com/esorf","followers_url":"https://api.github.com/users/esorf/followers","following_url":"https://api.github.com/users/esorf/following{/other_user}","gists_url":"https://api.github.com/users/esorf/gists{/gist_id}","starred_url":"https://api.github.com/users/esorf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/esorf/subscriptions","organizations_url":"https://api.github.com/users/esorf/orgs","repos_url":"https://api.github.com/users/esorf/repos","events_url":"https://api.github.com/users/esorf/events{/privacy}","received_events_url":"https://api.github.com/users/esorf/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-03-03T04:59:48Z","updated_at":"2015-03-08T10:56:39Z","closed_at":"2015-03-08T10:56:39Z","body":"The expectation for map and flatMap is that they pass each element of the _first_ level sequence to the function. Similarly, flatten needs to work on just _one_ level.\r\n\r\nWhat is currently implemented is interesting, but non-standard. The current map descends a tree of Mappables returning the same structure with the function applied to all non-mappable items. Maybe it should be called ```deepMap```. (And if it were implemented, it should have a mechanism for reconstituting the actual type of sequences in the returned data structure. In the example below, Group objects came back as basic Sequence objects.)\r\n\r\nAs an example of why this is simply broken, the first thing I needed from OCTotallyLazy was to \r\n````\r\n    NSArray *groups = [dataArray groupBy:groupingFn];\r\n    NSArray *nodes = [groups map:^MyNodeType(Group *g) {\r\n        // Make a node based on the property of the group\r\n        return node;\r\n    }];\r\n````\r\nOf course it didn't work, because Group is a Sequence which is Mappable. So instead of getting called with the groups I know to be in ```groups```, my mapping function got called with all the items in each of my groups."},"comment":{"url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/comments/77743381","html_url":"https://github.com/stuartervine/OCTotallyLazy/issues/20#issuecomment-77743381","issue_url":"https://api.github.com/repos/stuartervine/OCTotallyLazy/issues/20","id":77743381,"user":{"login":"stuartervine","id":646331,"avatar_url":"https://avatars.githubusercontent.com/u/646331?v=3","gravatar_id":"","url":"https://api.github.com/users/stuartervine","html_url":"https://github.com/stuartervine","followers_url":"https://api.github.com/users/stuartervine/followers","following_url":"https://api.github.com/users/stuartervine/following{/other_user}","gists_url":"https://api.github.com/users/stuartervine/gists{/gist_id}","starred_url":"https://api.github.com/users/stuartervine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stuartervine/subscriptions","organizations_url":"https://api.github.com/users/stuartervine/orgs","repos_url":"https://api.github.com/users/stuartervine/repos","events_url":"https://api.github.com/users/stuartervine/events{/privacy}","received_events_url":"https://api.github.com/users/stuartervine/received_events","type":"User","site_admin":false},"created_at":"2015-03-08T10:56:39Z","updated_at":"2015-03-08T10:56:39Z","body":"I have no idea why I made map lift mappables... but thanks for fixing it, I've merged your pull request."}}