Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seems
many_select
is broken as far as satisfying the co-monad laws for co-bind / extend. I'm under the impression thatmany_select
was intended to be co-bind/extend because it says so in the docstring and Bart de Smet mentions as much here.The main issue is that
first
is notextract
, as implemented. It should have typeObservable[a] -> a
but instead has typeObservable[a] -> Observable[a]
. Thus, this test fails because ofextract
. Note thatfirst
could be a lawful `extract, based on these laws (I briefly worked them out on paper).Actually, the types are just all weird, because you can't go from
Observable[a] -> a
, becausefirst
isn'textract
:Observable[a] ->
(private: after calling
map(ChainedObservable)
)Observable[Observable[a]] ->
(after applying
selector: Observable[a] -> Observable[b]
, which should have beenObservable[a] -> b
)Observable[Observable[b]]
(should have beenObservable[b]
)In fact, I don't think there's any method in rx with type
Observable[a] -> b
, since the only thing that looks like that issubscribe: Observer[a, b] -> Observable[a] -> "b"
whereb
is the type of the side-effect andsubscribe
actually returns unit/void.That said, a possible candidate for
extract
could be something likeo.first().to_future()
, which does have typeObservable[a] -> b
(or reallyObservable[Future[a]] -> Future[b]
, but whatever).The second issue is that this implementation doesn't do anything interesting with
extend
/many_select
. As far as I can tell (because the code is magic),The third issue is that I think it's broken. The implementation, both here and in RxJS, is some serious magic. The tests in RxJS are the same (and thus also trivial), so I'm not convinced that this has ever worked. I gather that we're supposed to get something like:
but instead we get `Observable([1], [2], [3]). I think RxJS is similarly broken.
Given these issues, I think some action items are
many_select
as implemented, since it doesn't do anything), or fixmany_select
so it works like .NET.extract
, probably aso.first().to_future()
I'm going to try to fix
many_select
, and just make the tests accommodate the fact that we don't have anextract
.