-
Notifications
You must be signed in to change notification settings - Fork 28
provide filter for Alternative and Monad? #43
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
Comments
Sounds useful, but we should consider using |
Technically we need :: ∀ m a. Plus m => Chain m => Applicative m => (a -> Boolean) -> m a -> m a But if we should use one from About proving something don't know, there are cople filter and filterMap related laws in Filterable. (btw filterMap could be implemented this way too) I think these are correct assumptions: (filter g) <<< (filter f) = filter (\x -> f x || g x) -- composition?
(filter f) <<< (filter f) = filter f -- ???
filter (const true) = id -- identity? |
You can prove things with just
I don't think
However, I'm struggling to think of a concrete type for which this would be useful. For sequence types like List or Array which have a concat-mappy Bind instance, this will do the same as your standard I'm going to close this for now for this reason plus the fact that it hasn't been touched in a long time, but please feel free to comment if I'm missing something. |
This might be correct: -(filter g) <<< (filter f) = filter (\x -> f x || g x)
+(filter g) <<< (filter f) = filter (\x -> f x && g x) (not posting with intent to reopen this issue tho) |
Oh yeah of course, that certainly seems more plausible. |
We can define filter which work on any Alternative and Monad
I think this repo is best place for it, but i might be wrong.
The text was updated successfully, but these errors were encountered: