Module
Data.Witherable
- Package
- purescript-filterable
- Repository
- LiamGoodacre/purescript-filterable
#Witherable Source
class (Filterable t, Traversable t) <= Witherable t where
Witherable
represents data structures which can be partitioned with
effects in some Applicative
functor.
wilt
- partition a structure with effectswither
- filter a structure with effects
Laws:
- Identity:
wither (pure <<< Just) ≡ pure
- Composition:
Compose <<< map (wither f) <<< wither g ≡ wither (Compose <<< map (wither f) <<< g)
- Multipass partition:
wilt p ≡ map partitioned <<< traverse p
- Multipass filter:
wither p ≡ map filtered <<< traverse p
Superclass equivalences:
partitionMap p = runIdentity <<< wilt (Identity <<< p)
filterMap p = runIdentity <<< wither (Identity <<< p)
traverse f ≡ wither (map Just <<< f)
Default implementations are provided by the following functions:
partitionMapByWilt
filterMapByWither
traverseByWither
Members
wilt :: forall r l a m. Applicative m => (a -> m (Either l r)) -> t a -> m { left :: t l, right :: t r }
wither :: forall b a m. Applicative m => (a -> m (Maybe b)) -> t a -> m (t b)
Instances
Witherable Array
Witherable List
(Ord k) => Witherable (Map k)
Witherable Maybe
(Monoid m) => Witherable (Either m)
#partitionMapByWilt Source
partitionMapByWilt :: forall r l a t. Witherable t => (a -> Either l r) -> t a -> { left :: t l, right :: t r }
A default implementation of parititonMap
given a Witherable
.
#filterMapByWither Source
filterMapByWither :: forall b a t. Witherable t => (a -> Maybe b) -> t a -> t b
A default implementation of filterMap
given a Witherable
.
#traverseByWither Source
traverseByWither :: forall b a m t. Witherable t => Applicative m => (a -> m b) -> t a -> m (t b)
A default implementation of traverse
given a Witherable
.
#wilted Source
wilted :: forall r l m t. Witherable t => Applicative m => t (m (Either l r)) -> m { left :: t l, right :: t r }
Partition between Left
and Right
values - with effects in m
.
#withered Source
withered :: forall x m t. Witherable t => Applicative m => t (m (Maybe x)) -> m (t x)
Filter out all the Nothing
values - with effects in m
.
Re-exports from Data.Filterable
#Filterable Source
class (Functor f) <= Filterable f
Filterable
represents data structures which can be partitioned/filtered.
partitionMap
- partition a data structure based on an either predicate.partition
- partition a data structure based on boolean predicate.filterMap
- map over a data structure and filter based on a maybe.filter
- filter a data structure based on a boolean.
Laws:
map f ≡ filterMap (Just <<< f)
filter ≡ filterMap <<< maybeBool
filterMap p ≡ filter (isJust <<< p)
Default implementations are provided by the following functions:
partitionDefault
partitionDefaultFilter
partitionDefaultFilterMap
filterDefault
filterDefaultPartition
filterDefaultPartitionMap
Instances
Filterable Array
Filterable Maybe
(Monoid m) => Filterable (Either m)
Filterable List
(Ord k) => Filterable (Map k)
#partitioned Source
partitioned :: forall r l f. Filterable f => f (Either l r) -> { left :: f l, right :: f r }
#filtered Source
filtered :: forall a f. Filterable f => f (Maybe a) -> f a
Filter out all the Nothing
values.
- Modules
- Data.
Filterable - Data.
Witherable