class Functor f => Filterable f
Like Functor, but you can remove elements instead of updating them.
Formally, the class Filterable represents a functor from Kleisli Maybe to Hask.
A definition of mapMaybe must satisfy the following laws:
- conservation
mapMaybe (Just . f) ≡ fmap f
- composition
mapMaybe f . mapMaybe g ≡ mapMaybe (f <=< g)
mapMaybe :: (a -> Maybe b) -> f a -> f b
Like mapMaybe.
catMaybes :: f (Maybe a) -> f a
catMaybes ≡ mapMaybe id
filter :: (a -> Bool) -> f a -> f a
filter f . filter g ≡ filter (liftA2 (&&) g f)
drain :: f a -> f b
Empty a filterable.
drain ≡ mapMaybe (const Nothing)