
29 Jan
2014
29 Jan
'14
6:20 a.m.
On Tue, 28 Jan 2014 21:25:31 -0500, "Alvaro J. Genial"
1. Is there a more general version of `null`? (e.g. for a Monad, Functor, Applicative, Traversable or the like.) The closest I can come up with is, in decreasing clunkiness:
Lens can do this via the “hasn't” function for any Fold. You can get some free generalization out of it via “hasn't each”, which works for every instance of Each (includes most Foldable containers along with ByteString, Text, and similar).
2. In that vein, is there an existing function for "a value or a default if it's zero"? E.g.:
This abstraction looks a lot like what you'd want out of Alternative, though admittedly that one is specialized to (* -> *).