-
Notifications
You must be signed in to change notification settings - Fork 182
Add Data.Set.catMaybes and Data.Set.mapMaybe? #346
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
Hm, catMaybes = filter isJust
mapMaybe f = filter isJust . map f these are a little shorter than what you've written, and don't seem too bad. |
These would have the wrong result type ( |
Ah - yup! Blah. Carry on then |
Can you explain more about when you need these? I'm not opposed, but would catMaybes can be implemented efficiently using the current API: catMaybes xs = case minView xs of However, it's not clear to me why you would build a Set of Maybes to begin I don't know of a way to implement mapMaybe much (if at all) better than On Oct 6, 2016 5:10 AM, "Simon Jakobi" [email protected] wrote:
|
I found a simpler version of catMaybes, using a function new in the latest catMaybes = mapMonotonic fromJust . dropWhileAntitone isNothing On Nov 12, 2016 6:52 PM, "David Feuer" [email protected] wrote:
|
This version of Regarding |
Also missing: Data.Sequence.mapMaybe :: (a -> Maybe b) -> Seq a -> Seq b |
I just found myself wanting |
Wouldn't it be better if |
|
I just spent a few minutes searching for |
My concern remains: |
Add a comment? |
Okay, fine. |
Sounds good to add (btw |
Recovering mapMaybe :: (a -> Maybe b) -> Seq a -> Seq b
mapMaybe f = fromList . Data.Maybe.mapMaybe f . toList |
I think it's reasonable to expect |
It's worth checking both options. The fold is perfectly reasonable too, for both of them. What's not reasonable is using |
Oh of course, I guess this was a misunderstanding. I suggested defining |
The types should be the following:
Currently I often use
Set.fromList . mapMaybe f . Set.toList
which I find rather tedious.The text was updated successfully, but these errors were encountered: