Proposal: Add bool to Data.Bool

Edward Kmett ekmett at gmail.com
Wed Sep 11 00:20:06 CEST 2013


+1 for it without bikeshedding

-Ed

On Sep 10, 2013, at 6:07 PM, Dag Odenhall <dag.odenhall at gmail.com> wrote:

> +1, I‘ve often wanted this but don’t want to add a dependency just for bool, so I end up writing it myself, locally in a where every time, which doesn't feel very Haskelly to do!
> 
> I would even like it in Prelude, but I expect that to get much more opposition so this proposal should probably not discuss that possibility at all.
> 
> 
> 
> On Wed, Sep 11, 2013 at 12:02 AM, Oliver Charles <ollie at ocharles.org.uk> wrote:
>> Hello,
>> 
>> 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 [1] shows five equivalent
>> functions on the first page - and I'm sure there are more on subsequent
>> pages.
>> 
>> Thoughts?
>> - ocharles
>> 
>> ---
>> [1]:
>> https://www.fpcomplete.com/hoogle?q=Bool+-%3E+a+-%3E+a+-%3E+a&env=ghc-7.4.2-stable-13.09
>> 
>> 
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://www.haskell.org/mailman/listinfo/libraries
> 
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://www.haskell.org/mailman/listinfo/libraries
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/libraries/attachments/20130910/2efe1601/attachment.htm>


More information about the Libraries mailing list