| Copyright | (c) Fumiaki Kinoshita 2019 |
|---|---|
| License | BSD3 |
| Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
| Stability | stable |
| Portability | non-portable |
| Safe Haskell | None |
| Language | Haskell2010 |
Data.Witherable.Class
Description
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:
Methods
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(fmapJust. f) ≡traversef- composition
Compose.fmap(witherf) .witherg ≡wither(Compose.fmap(witherf) . g)
Parametricity implies the naturality law:
t .witherf ≡wither(t . f)
Minimal complete definition
Nothing
Methods
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 #