
I think "partial" is already used for Maybe somewhere, but cond sounds fine.
On Dec 24, 2014 10:33 AM, "Yitzchak Gale"
Nikita Volkov wrote:
I propose to add the following utility function into |Control.Applicative|: |cond :: (Alternative f) => (a -> Bool) -> a -> f a cond p a = if p a then pure a else empty
Roman Cheplyaka wrote:
* guardp (for "predicate") * guardf (for "function") * guardWith I wouldn't be opposed to cond, either.
Oliver Charles wrote:
I tend to use `pure` and `mfilter` for this case: \x -> fromMaybe 0 $ mfilter (> 0) $ pure (x - 10)
I reach for this all the time and find it lacking. In an attempt to be merciful to some of my readers, I avoid Ollie's very nice mfilter solution and refactor instead.
+1
Regarding the name - all of the suggestions of Nikita and Roman are fine with me. Let's just build this bikeshed!
Thanks, Yitz _______________________________________________ Libraries mailing list Libraries@haskell.org http://www.haskell.org/mailman/listinfo/libraries