Copyright | (c) Fumiaki Kinoshita 2019 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Stability | stable |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Synopsis
- class Functor f => Filterable f where
- class (Traversable t, Filterable t) => Witherable t where
- wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b)
- witherM :: Monad m => (a -> m (Maybe b)) -> t a -> m (t b)
- filterA :: Applicative f => (a -> f Bool) -> t a -> f (t a)
Documentation
class Functor f => Filterable f where Source #
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:
mapMaybe :: (a -> Maybe b) -> f a -> f b Source #
Like mapMaybe
.
Instances
class (Traversable t, Filterable t) => Witherable t where Source #
An enhancement of Traversable
with Filterable
A definition of wither
must satisfy the following laws:
- conservation
wither
(fmap
Just
. f) ≡traverse
f- composition
Compose
.fmap
(wither
f) .wither
g ≡wither
(Compose
.fmap
(wither
f) . g)
Parametricity implies the naturality law:
t .wither
f ≡wither
(t . f)
Nothing
wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b) Source #
witherM :: Monad m => (a -> m (Maybe b)) -> t a -> m (t b) Source #
Monadic variant of wither
. This may have more efficient implementation.
filterA :: Applicative f => (a -> f Bool) -> t a -> f (t a) Source #