New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<RACStream> monad, RACSequence #92
Conversation
Also fixed some header visibility attributes.
Although not necessarily part of the definition of a monad (though Haskell's MonadPlus includes it), it's useful for our stream abstraction.
This is equivalent to mplus.
Although equivalent to monadic join, and thus technically redundant in the presence of bind, it'll be extremely convenient to have. Without lazy evaluation, it's quite hard to implement a generic, cheap join.
I don't like methods being declared as properties when they're not KVO compliant, but I understand |
so it doesn't have to be a required method. |
BTW, I fully expect some |
|
||
// Returns all but the first `count` objects in the sequence. If `count` exceeds | ||
// the number of items in the sequence, nil is returned. | ||
- (RACSequence *)drop:(NSUInteger)count; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would this need to be on RACSequence
instead of RACStream
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He did mention he still had to move some methods from RACSequence
and RACSubscribable
to RACStream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, @Coneko nailed it. This was added before the protocol (just to demonstrate to myself that the primitives I had were good enough). It's going to go into <RACStream>
later.
Overall I ❤️ ❤️ ❤️ the direction this is going 👍 |
#import "EXTConcreteProtocol.h" | ||
|
||
// A concrete protocol representing any stream of values. Implemented by | ||
// RACSubscribable and RACStream. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pretty sure you mean RACSequence
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
derp
@Coneko Good call on the default implementation of Although |
The use case is too narrow, and it's trivial to implement from scratch.
Added rac_keySequence for the old behavior.
<RACStream>'s implementation is good enough now that we have lazy -bind:.
<RACSubscribable> implicitly includes it.
Left +merge: as-is, because its naming is clearer when given an array of subscribables to combine.
I still can't think of a solution to the |
Why not take the easy way out and have |
Yeah, though I bet |
It's worth noting that sequences have a similar, though less severe, problem. It'd be nice to have a generic solution for |
// Appends the values of `stream` to the values in the receiver. | ||
// | ||
// stream - A stream to concatenate. This must be an instance of the same | ||
// concrete class as the receiver, and should not be `nil`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should change stream
to be id
instead of id<RACStream>
since all other cases where a stream of the same type was required have been typed with just id
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those cases (return types of blocks) have been because of Objective-C's limited type system. When we can type things as id<RACStream>
without issue, we should.
It mimics the "terminating subscriptions immediately" issue in #94 doesn't it? In both cases the existing interface is elegant, but doesn't cover some very particular edge cases, and having to dirty the interface to cover them is frustrating. On an unrelated note, how come sequences only have a class cluster, and not a concrete protocol too like subscribables? |
I think if you have a type that you want to be sequencable, it's trivial to write an adapter, just like what's done for the built-in collection classes right now. Honestly, I would rather subscribables not be a protocol, but there are some legitimate use cases for it that I don't find as applicable to sequences. See #35 for some more discussion. |
This includes class/protocol info too, unlike _cmd.
(But still return values.)
Added |
I'd say |
There is a semantic difference between returning |
Alright so the one last thing. We talked about this in person, but I think it's better to go back to |
💥 |
Conflicts: ReactiveCocoaFramework/ReactiveCocoa/RACSubscribableProtocol.h
✊ 👊 ✌️ |
<RACStream> monad, RACSequence
Disable broken UIDatePicker test
#89
Added a lazy
RACSequence
class, and abstracted common APIs between it and<RACSubscribable>
into a new<RACStream>
protocol. I'm definitely open to better names for these guys.RAC should be tagged before this gets merged in.