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:
zero :: (MonadPlus m, Eq (m a)) => m a -> Boolzero = m == mzero
zero :: (Alternative f, Eq (f a)) => f a -> Boolzero = m == emptyzero :: (Monoid m, Eq m) => m -> Boolzero = m == memptyThough requiring Eq seems ugly and unnecessary, in theory.
2. In that vein, is there an existing function for "a value or a default if it's zero"? E.g.:orElse :: (Monoid m) => m -> m -> ma `orElse` b = if zero a then b else aThank you,Alvaro
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe