Proposal: Add bool to Data.Bool
danburton.email at gmail.com
Wed Sep 11 02:17:12 CEST 2013
+1 for Data.Bool.bool :: a -> a -> Bool -> a. It doesn't seem very
important but it does add symmetry with maybe and either, and is mostly
harmless residing in Data.Bool as long as it is not re-exported by Prelude.
On a tangent... as usual, the Applicative instance of (a ->) comes in handy
for pointless programming:
cond = liftA3 bool :: (a -> b) -> (a -> b) -> (a -> Bool) -> a -> b
-- Dan Burton
On Tue, Sep 10, 2013 at 4:01 PM, Christopher Done <chrisdone at gmail.com>wrote:
> FWIW I've added this to data-extra
> http://chrisdone.com/data-extra/Data-Bool-Extra.html for the meanwhile.
> On 11 September 2013 00:02, Oliver Charles <ollie at ocharles.org.uk> wrote:
>> I would like to propose that the following is added to Data.Bool in base:
>> bool :: a -> a -> Bool -> a
>> bool f _ False = f
>> bool _ t True = t
>> (Aka, bool f t b = if b then t else f)
>> The purpose of this is hopefully evident from its definition. I find
>> myself reaching for this in cases similar to where I would use 'maybe' -
>> often when I'm working with 'fmap' and don't want to start introducing
>> names for the function I am using to map over some functor.
>> I suggested this in #haskell and other people also seem frustrated this
>> doesn't exist, and would like to see it happen - hopefully they will
>> voice their support as a reply here.
>> A quick search on FPComplete's Hoogle  shows five equivalent
>> functions on the first page - and I'm sure there are more on subsequent
>> - ocharles
>> Libraries mailing list
>> Libraries at haskell.org
> Libraries mailing list
> Libraries at haskell.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Libraries