Empty- A type class for empty containers

Safe HaskellNone




class HasEmpty f where Source #

The class of type of * -> * which may be empty. There is only one law for HasEmpty and its enforced by the type. The law is that there exists a value in type f for which a is fully generic. This alone is often enough to uniquely determine the value for a given, data type.

Additional laws for HasEmpty work backwards, empty has a relationships with other classes. So if f is a member of one of these classes, the following should hold.

Functor identity
g <$> empty = empty
Applicative annihilation left
x <*> empty = empty
Applicative annihilation right
empty <*> x = empty
Monad identity
empty >>= f = empty
Alternative empty
empty = Alternative.empty
MonadPlus mzero
empty = mzero
Foldable identity
foldr f x empty = empty


empty :: forall a. f a Source #

empty :: Alternative f => f a Source #

coerce :: HasEmpty f => a -> f b Source #

isEmpty :: (HasEmpty f, Eq (f a)) => f a -> Bool Source #