darcs patch: Add justIf to Data.Maybe

Johan Tibell johan.tibell at gmail.com
Wed Aug 26 14:03:48 EDT 2009

On Tue, Aug 25, 2009 at 1:11 PM, Yitzchak Gale<gale at sefer.org> wrote:
> Johan Tibell wrote:
>> Are all these small little functions
>> really worth it?
>> They're trivially defined using the current API...
>> let developers use composition to define the rest?
> I completely agree with you. But in this case, even
> though these functions really are trivial, they come
> up *all* the time, and there is just something awkward
> about them.
> We certainly won't add more than one of the two:
> justIf x b = guard b >> return x
> check p x = guard (p x) >> return x

As you showed they are awkward to express in point-free style but as
you demonstrated above they're trivially expressed using the monadic
operators and guard. That several people want several different
variation also suggests that the proposed version perhaps isn't useful
enough to warrant inclusion in the library.



More information about the Libraries mailing list