Proposal: Add bool to Data.Bool
ollie at ocharles.org.uk
Wed Sep 11 00:02:19 CEST 2013
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
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 490 bytes
Desc: OpenPGP digital signature
More information about the Libraries