Class of filtrable containers, i.e. containers we can map over while selectively dropping elements.
Laws:
mapMaybe Just = idmapMaybe f = catMaybes ∘ fmap fcatMaybes = mapMaybe idfilter f = mapMaybe (\ x -> bool Nothing (Just x) (f x))mapMaybe g . mapMaybe f = mapMaybe (g <=< f)
Laws if Foldable f:
Methods
mapMaybe :: (a -> Maybe b) -> f a -> f bMap the container with the given function, dropping the elements for which it returns Nothing.
catMaybes :: f (Maybe a) -> f afilter :: (a -> Bool) -> f a -> f aDrop the elements for which the given predicate is False.
mapMaybeA :: (Traversable f, Applicative p) => (a -> p (Maybe b)) -> f a -> p (f b)Traverse the container with the given function, dropping the elements for which it returns Nothing.
filterA :: (Traversable f, Applicative p) => (a -> p Bool) -> f a -> p (f a)Drop the elements for which the given predicate is False.
mapEither :: (a -> Either b c) -> f a -> (f b, f c)mapEitherA :: (Traversable f, Applicative p) => (a -> p (Either b c)) -> f a -> p (f b, f c)partitionEithers :: f (Either a b) -> (f a, f b)
Instances9Filtrable, …
Filtrable MaybeDefined in filtrable-0.1.6.0 · Data.FiltrableFiltrable []Defined in filtrable-0.1.6.0 · Data.FiltrableFiltrable ProxyDefined in filtrable-0.1.6.0 · Data.FiltrableFiltrable (Const a)Defined in filtrable-0.1.6.0 · Data.FiltrableFiltrable f => Filtrable (Backwards f)Defined in filtrable-0.1.6.0 · Data.FiltrableFiltrable f => Filtrable (Reverse f)Defined in filtrable-0.1.6.0 · Data.Filtrable(Filtrable f, Filtrable g) => Filtrable (Product f g)Defined in filtrable-0.1.6.0 · Data.Filtrable(Filtrable f, Filtrable g) => Filtrable (Sum f g)Defined in filtrable-0.1.6.0 · Data.Filtrable(Functor f, Filtrable g) => Filtrable (Compose f g)Defined in filtrable-0.1.6.0 · Data.Filtrable