{"action":"created","issue":{"url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/99","labels_url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/99/labels{/name}","comments_url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/99/comments","events_url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/99/events","html_url":"https://github.com/fantasyland/fantasy-land/issues/99","id":95702885,"number":99,"title":"cps version of `chain`","user":{"login":"srijs","id":2677165,"avatar_url":"https://avatars.githubusercontent.com/u/2677165?v=3","gravatar_id":"","url":"https://api.github.com/users/srijs","html_url":"https://github.com/srijs","followers_url":"https://api.github.com/users/srijs/followers","following_url":"https://api.github.com/users/srijs/following{/other_user}","gists_url":"https://api.github.com/users/srijs/gists{/gist_id}","starred_url":"https://api.github.com/users/srijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srijs/subscriptions","organizations_url":"https://api.github.com/users/srijs/orgs","repos_url":"https://api.github.com/users/srijs/repos","events_url":"https://api.github.com/users/srijs/events{/privacy}","received_events_url":"https://api.github.com/users/srijs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-17T17:20:37Z","updated_at":"2015-07-18T14:48:35Z","closed_at":null,"body":"In light of the coming support for tail-call optimisation in ES6, I'd like to propose the following addition to `Functor`:\r\n\r\n    tailMap :: (a -> (b -> (f b -> c) -> c) -> c ) -> f a -> c\r\n\r\nSuch that:\r\n\r\n    tailMap (\\a g -> g (f a) id) == map f\r\n\r\nCombined with `join`, it allows us to construct `tailChain`:\r\n\r\n    var join = function (mm) {\r\n      return mm.chain(function (m) { return m; });\r\n    };\r\n\r\n    var tailChain = function (m, fn) {\r\n      return m.tailMap(function (a, wrap) {\r\n        return fn(a, function (b, cb) {\r\n          return wrap(b, function (mm) {\r\n            return cb(join(mm));\r\n          });\r\n        });\r\n      });\r\n    };\r\n\r\nUsing continuation passing style, `tailChain` can take advantage of tail-call optimisation and eliminate the need for trampolining when sequencing a large number of actions."},"comment":{"url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/comments/122550429","html_url":"https://github.com/fantasyland/fantasy-land/issues/99#issuecomment-122550429","issue_url":"https://api.github.com/repos/fantasyland/fantasy-land/issues/99","id":122550429,"user":{"login":"CrossEye","id":151263,"avatar_url":"https://avatars.githubusercontent.com/u/151263?v=3","gravatar_id":"","url":"https://api.github.com/users/CrossEye","html_url":"https://github.com/CrossEye","followers_url":"https://api.github.com/users/CrossEye/followers","following_url":"https://api.github.com/users/CrossEye/following{/other_user}","gists_url":"https://api.github.com/users/CrossEye/gists{/gist_id}","starred_url":"https://api.github.com/users/CrossEye/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CrossEye/subscriptions","organizations_url":"https://api.github.com/users/CrossEye/orgs","repos_url":"https://api.github.com/users/CrossEye/repos","events_url":"https://api.github.com/users/CrossEye/events{/privacy}","received_events_url":"https://api.github.com/users/CrossEye/received_events","type":"User","site_admin":false},"created_at":"2015-07-18T14:48:35Z","updated_at":"2015-07-18T14:48:35Z","body":"Ok, @bergus, how do people always beat me to these things by minutes?\r\n\r\nI was going to ask exactly the same thing!"}}