You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Creating this issue to investigate how we could make Kefir compatible with the Fantasy Land Specification.
I 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.
In 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):
One 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.
Here we have the same problem as in reduce — unable to return result value directly:
// we can't do this
Observavble (f a) -> f (Observable a)
// only can do this (based on reduce)
Observavble (f a) -> Observable (f (Observable a))
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:
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)
Although 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 :)
For better understanding here is how sequence for Array looks like:
Creating this issue to investigate how we could make Kefir compatible with the Fantasy Land Specification.
I 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.
In 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):
Setoid
a.equals(a)
– we can't implement this (?)Semigroup
a.concat(b)
—obsA.concat(obsB)
(?)Monoid
m.empty()
—Kefir.never()
(?)Functor
u.map(f)
—obs.map(f)
Apply
a.ap(b)
— can be implemented on top ofcombine
, although would be better for us (for performance) if FL would require liftN instead of apApplicative
a.of(x)
—Kefir.constant(x)
(?)Foldable
u.reduce(f, x)
—Kefir.scan(f, x).last()
(?)One 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.
Traversable
u.sequence(of)
— not sure...Here we have the same problem as in
reduce
— unable to return result value directly: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:Although the other way around form of
sequence
—f (Observable a) -> Observavble (f a)
seems very similar toKefir.combine :: [Observable] -> Observable []
. Not sure what it gives us though :)For better understanding here is how
sequence
forArray
looks like:Chain / Monad
m.chain(f)
—obs.flatMap(f)
(?)Extend
w.extend(f)
— ?Comonad
w.extract()
— can't be implemented because of asynchronous nature of observables (?)The text was updated successfully, but these errors were encountered: