{"action":"created","issue":{"url":"https://api.github.com/repos/rpominov/kefir/issues/160","repository_url":"https://api.github.com/repos/rpominov/kefir","labels_url":"https://api.github.com/repos/rpominov/kefir/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/rpominov/kefir/issues/160/comments","events_url":"https://api.github.com/repos/rpominov/kefir/issues/160/events","html_url":"https://github.com/rpominov/kefir/issues/160","id":110858464,"number":160,"title":"Fantasy Land compatibility","user":{"login":"rpominov","id":825702,"avatar_url":"https://avatars.githubusercontent.com/u/825702?v=3","gravatar_id":"","url":"https://api.github.com/users/rpominov","html_url":"https://github.com/rpominov","followers_url":"https://api.github.com/users/rpominov/followers","following_url":"https://api.github.com/users/rpominov/following{/other_user}","gists_url":"https://api.github.com/users/rpominov/gists{/gist_id}","starred_url":"https://api.github.com/users/rpominov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpominov/subscriptions","organizations_url":"https://api.github.com/users/rpominov/orgs","repos_url":"https://api.github.com/users/rpominov/repos","events_url":"https://api.github.com/users/rpominov/events{/privacy}","received_events_url":"https://api.github.com/users/rpominov/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rpominov/kefir/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2015-10-11T14:14:40Z","updated_at":"2016-08-17T12:58:37Z","closed_at":null,"body":"Creating this issue to investigate how we could make Kefir compatible with the [Fantasy Land Specification](https://github.com/fantasyland/fantasy-land).\r\n\r\nI think of two possibilities: add Fantasy Land methods directly into Kefir, or create a plugin as a separate npm package that injects Fantasy Land methods into Kefir. Don't know what is better for us yet, and would like to know your opinions.\r\n\r\nIn either way first we need to find out how Fantasy Land methods map to current Kefir methods. Here is a draft of such mapping (not sure if it's correct and complete; will update it in progress):\r\n\r\n## [Setoid](https://github.com/fantasyland/fantasy-land#setoid)\r\n\r\n`a.equals(a)` – we can't implement this (?)\r\n\r\n## [Semigroup](https://github.com/fantasyland/fantasy-land#semigroup)\r\n\r\n`a.concat(b)` — `obsA.concat(obsB)` (?)\r\n\r\n## [Monoid](https://github.com/fantasyland/fantasy-land#monoid)\r\n\r\n`m.empty()` — `Kefir.never()` (?)\r\n\r\n## [Functor](https://github.com/fantasyland/fantasy-land#functor)\r\n\r\n`u.map(f)` — `obs.map(f)`\r\n\r\n## [Apply](https://github.com/fantasyland/fantasy-land#apply)\r\n\r\n`a.ap(b)` — can be implemented on top of `combine`, although would be better for us (for performance) if FL would require [liftN instead of ap](https://github.com/fantasyland/fantasy-land/issues/56)\r\n\r\n## [Applicative](https://github.com/fantasyland/fantasy-land#applicative)\r\n\r\n`a.of(x)` — `Kefir.constant(x)` (?)\r\n\r\n## [Foldable](https://github.com/fantasyland/fantasy-land#foldable)\r\n\r\n`u.reduce(f, x)` — `Kefir.scan(f, x).last()` (?)\r\n\r\nOne problem is that we can't return the result value directly but can only return an observable containing result value. Although FL seem to not require that.\r\n\r\n## [Traversable](https://github.com/fantasyland/fantasy-land#traversable)\r\n\r\n`u.sequence(of)` — not sure...\r\n\r\nHere we have the same problem as in `reduce` — unable to return result value directly:\r\n\r\n```\r\n// we can't do this\r\nObservavble (f a) -> f (Observable a)\r\n\r\n// only can do this (based on reduce)\r\nObservavble (f a) -> Observable (f (Observable a))\r\n```\r\n\r\n`Observable (f (Observable a))` already doesn't seem to be very useful, but the main problem is that we can't satisfy the following law:\r\n\r\n> `t(u.sequence(f.of))` is equivalent to `u.map(t).sequence(g.of)` where `t` is a natural transformation from `f` to `g` (naturality)\r\n\r\nAlthough the other way around form of `sequence` — `f (Observable a) -> Observavble (f a)` seems very similar to `Kefir.combine :: [Observable] -> Observable []`. Not sure what it gives us though :)\r\n\r\nFor better understanding here is how `sequence` for `Array` looks like:\r\n```js\r\nArray.prototype.sequence = function(of) {\r\n  return this.reduce((r, i) => r.map(xs => x => xs.concat(x)).ap(of(i)), of([]))\r\n}\r\n```\r\n\r\n## [Chain](https://github.com/fantasyland/fantasy-land#chain) / [Monad](https://github.com/fantasyland/fantasy-land#monad)\r\n\r\n`m.chain(f)` — `obs.flatMap(f)` (?)\r\n\r\n## [Extend](https://github.com/fantasyland/fantasy-land#extend)\r\n\r\n`w.extend(f)` — ?\r\n\r\n## [Comonad](https://github.com/fantasyland/fantasy-land#comonad)\r\n\r\n`w.extract()` — can't be implemented because of asynchronous nature of observables (?)"},"comment":{"url":"https://api.github.com/repos/rpominov/kefir/issues/comments/240402935","html_url":"https://github.com/rpominov/kefir/issues/160#issuecomment-240402935","issue_url":"https://api.github.com/repos/rpominov/kefir/issues/160","id":240402935,"user":{"login":"rpominov","id":825702,"avatar_url":"https://avatars.githubusercontent.com/u/825702?v=3","gravatar_id":"","url":"https://api.github.com/users/rpominov","html_url":"https://github.com/rpominov","followers_url":"https://api.github.com/users/rpominov/followers","following_url":"https://api.github.com/users/rpominov/following{/other_user}","gists_url":"https://api.github.com/users/rpominov/gists{/gist_id}","starred_url":"https://api.github.com/users/rpominov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpominov/subscriptions","organizations_url":"https://api.github.com/users/rpominov/orgs","repos_url":"https://api.github.com/users/rpominov/repos","events_url":"https://api.github.com/users/rpominov/events{/privacy}","received_events_url":"https://api.github.com/users/rpominov/received_events","type":"User","site_admin":false},"created_at":"2016-08-17T12:58:37Z","updated_at":"2016-08-17T12:58:37Z","body":"We still don't have Fantasy Land compatibility, but I've just added Static Land support http://rpominov.github.io/kefir/#static-land"}}
{"actor":{"display_login":"rpominov"}}