-
Notifications
You must be signed in to change notification settings - Fork 10
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
Flowtype and .filter() #11
Comments
Hi @Leeds-eBooks, The problem is that filter returns the same type Essentially what you want is to restrict the type, but you probably don't need to. I would suggest allowing the Alternatively you may want to look at type aliases, or classes to represent your user objects instead. Thanks! |
Also conceptually, filter shouldn't change the value of A. What you're after is actually similar to Scala's collect() which is like |
What about: |
@maartenschumacher That works a treat, thanks so much. @alexanderjarvis would it make sense to add this method to collect(p: (A) => boolean): Maybe<B> {
if (p(this.value)) {
return just(this.value)
} else {
return nothing
}
} That's probably all wrong but just for illustrative purposes. |
How would you define |
I have been looking at the
maybe
source code and trying to work out how to improve the typing of the.filter()
method but I haven't worked anything out. The problem is below. Is it possible to fix this withinmaybe
or is flow not able to handle this anyway yet?The text was updated successfully, but these errors were encountered: