Copyright | (c) Fumiaki Kinoshita 2015 |
---|---|
License | BSD3 |
Maintainer | Fumiaki Kinoshita <fumiexcel@gmail.com> |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- class Traversable t => Witherable t where
- witherM :: (Witherable t, Monad m) => (a -> MaybeT m b) -> t a -> m (t b)
- blightM :: (Monad m, Witherable t) => t a -> (a -> MaybeT m b) -> m (t b)
- newtype Chipped t a = Chipped {
- getChipped :: t (Maybe a)
Documentation
class Traversable t => Witherable t where Source
Like traverse
, but you can remove elements instead of updating them.
traverse
f ≡wither
(fmap
Just
. f)
A definition of wither
must satisfy the following laws:
- identity
wither
(pure
. Just) ≡pure
- composition
Compose . fmap (
wither
f) .wither
g ≡wither
(Compose . fmap (wither
f) . g)
Parametricity implies the naturality law:
t .wither
f =wither
(t . f)
Minimal complete definition: wither
or mapMaybe
or catMaybes
.
The default definitions can be overridden for efficiency.
Nothing
wither :: Applicative f => (a -> f (Maybe b)) -> t a -> f (t b) Source
mapMaybe :: (a -> Maybe b) -> t a -> t b Source
catMaybes :: t (Maybe a) -> t a Source
filterA :: Applicative f => (a -> f Bool) -> t a -> f (t a) Source
Witherable [] | |
Witherable Maybe | |
Witherable IntMap | |
Witherable Seq | |
Witherable Vector | |
Monoid e => Witherable (Either e) | |
Witherable (Const r) | |
Witherable (Proxy *) | |
Ord k => Witherable (Map k) | |
(Eq k, Hashable k) => Witherable (HashMap k) | |
Traversable t => Witherable (Chipped t) |
witherM :: (Witherable t, Monad m) => (a -> MaybeT m b) -> t a -> m (t b) Source
blightM :: (Monad m, Witherable t) => t a -> (a -> MaybeT m b) -> m (t b) Source
Traversable containers which hold Maybe
are witherable.
Chipped | |
|
Functor t => Functor (Chipped t) | |
Applicative t => Applicative (Chipped t) | |
Foldable t => Foldable (Chipped t) | |
Traversable t => Traversable (Chipped t) | |
Traversable t => Witherable (Chipped t) | |
Eq (t (Maybe a)) => Eq (Chipped t a) | |
Ord (t (Maybe a)) => Ord (Chipped t a) | |
Read (t (Maybe a)) => Read (Chipped t a) | |
Show (t (Maybe a)) => Show (Chipped t a) |