Module
Data.Filterable
- Package
- purescript-filterable
- Repository
- LiamGoodacre/purescript-filterable
#Filterable Source
class (Functor f) <= Filterable f where
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:
filterDefault
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 b
filter :: forall a. (a -> Boolean) -> f a -> f a
Instances
Filterable Array
Filterable Maybe
(Monoid m) => Filterable (Either m)
#eitherBool Source
eitherBool :: forall a. (a -> Boolean) -> a -> Either a a
Upgrade 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
.
#filterDefault Source
filterDefault :: forall a f. Filterable f => (a -> Boolean) -> f a -> f a
A default implementation of filter
using filterMap
.
#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.
#cleared Source
cleared :: forall b a f. Filterable f => f a -> f b
Filter out all values.
- Modules
- Data.
Filterable - Data.
Witherable