Data.Filterable
- Package
- purescript-filterable
- Repository
- LiamGoodacre/purescript-filterable
#Filterable Source
class (Functor f) <= Filterable f whereFilterable 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 <<< maybeBoolfilterMap p ≡ filter (isJust <<< p)
Default implementations are provided by the following functions:
partitionDefaultpartitionDefaultFilterpartitionDefaultFilterMapfilterDefaultfilterDefaultPartitionfilterDefaultPartitionMap
Members
partitionMap :: forall r l a. (a -> Either l r) -> f a -> { left :: f l, right :: f r }partition :: forall a. (a -> Boolean) -> f a -> { no :: f a, yes :: f a }filterMap :: forall b a. (a -> Maybe b) -> f a -> f bfilter :: forall a. (a -> Boolean) -> f a -> f a
Instances
Filterable ArrayFilterable Maybe(Monoid m) => Filterable (Either m)Filterable List(Ord k) => Filterable (Map k)
#eitherBool Source
eitherBool :: forall a. (a -> Boolean) -> a -> Either a aUpgrade a boolean-style predicate to an either-style predicate mapping.
#partitionDefault Source
partitionDefault :: forall a f. Filterable f => (a -> Boolean) -> f a -> { no :: f a, yes :: f a }A default implementation of partition using partitionMap.
#partitionDefaultFilter Source
partitionDefaultFilter :: forall a f. Filterable f => (a -> Boolean) -> f a -> { no :: f a, yes :: f a }A default implementation of partition using filter. Note that this is
almost certainly going to be suboptimal compared to direct implementations.
#partitionDefaultFilterMap Source
partitionDefaultFilterMap :: forall a f. Filterable f => (a -> Boolean) -> f a -> { no :: f a, yes :: f a }A default implementation of partition using filterMap. Note that this
is almost certainly going to be suboptimal compared to direct
implementations.
#filterDefault Source
filterDefault :: forall a f. Filterable f => (a -> Boolean) -> f a -> f aA default implementation of filter using filterMap.
#filterDefaultPartition Source
filterDefaultPartition :: forall a f. Filterable f => (a -> Boolean) -> f a -> f aA default implementation of filter using partition.
#filterDefaultPartitionMap Source
filterDefaultPartitionMap :: forall a f. Filterable f => (a -> Boolean) -> f a -> f aA default implementation of filter using partitionMap.
#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 aFilter out all the Nothing values.
#cleared Source
cleared :: forall b a f. Filterable f => f a -> f bFilter out all values.
- Modules
- Data.
Filterable - Data.
Witherable