
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 justIf = flip $ check . const check = ap justIf Perhaps the following is a bit of an explanation of why they feel awkward: <yitz> @pl \ p x -> guard (p x) >> return x <lambdabot> (`ap` return) . (((>>) . guard) .) <yitz> @pl \ p x -> if p x then return x else mzero <lambdabot> flip flip mzero . (`ap` return) . (if' .) Please note that if we choose to add justIf, it should be spelled with an uppercase 'I' to be consistent with Haskell conventions. Thanks, Yitz