Portability | non-portable (TF,GNTD) |
---|---|
Stability | experimental |
Maintainer | hans@hanshoglund.se |
Safe Haskell | Safe-Inferred |
Partial maps and filters over MonadPlus
instances.
This is especially useful for sequential structures such as event lists, tracks etc.
Inspired by the Conal Elliott's blog post:
- module Control.Monad
- msum :: MonadPlus m => [m a] -> m a
- msum' :: (MonadPlus m, Foldable t) => t (m a) -> m a
- mfold :: (MonadPlus m, Foldable t) => t a -> m a
- mfromList :: MonadPlus m => [a] -> m a
- mfromMaybe :: MonadPlus m => Maybe a -> m a
- mfilter' :: MonadPlus m => (a -> Bool) -> m a -> m a
- mpartition :: MonadPlus m => (a -> Bool) -> m a -> (m a, m a)
- mscatter :: MonadPlus m => m [b] -> m b
- mscatter' :: (MonadPlus m, Foldable t) => m (t b) -> m b
- mcatMaybes :: MonadPlus m => m (Maybe a) -> m a
- mlefts :: MonadPlus m => m (Either a b) -> m a
- mrights :: MonadPlus m => m (Either a b) -> m b
- mpartitionEithers :: MonadPlus m => m (Either a b) -> (m a, m b)
- mmapMaybe :: MonadPlus m => (a -> Maybe b) -> m a -> m b
- mconcatMap :: MonadPlus m => (a -> [b]) -> m a -> m b
Basics
module Control.Monad
msum' :: (MonadPlus m, Foldable t) => t (m a) -> m aSource
This generalizes the list-based concat
function.
Constructing
mfromList :: MonadPlus m => [a] -> m aSource
Translate a list to an arbitrary MonadPlus
type.
This function generalizes the listToMaybe
function.
mfromMaybe :: MonadPlus m => Maybe a -> m aSource
Translate maybe to an arbitrary MonadPlus
type.
This function generalizes the maybeToList
function.
Filtering
mpartition :: MonadPlus m => (a -> Bool) -> m a -> (m a, m a)Source
Special filters
mscatter :: MonadPlus m => m [b] -> m bSource
Pass through Just
occurrences.
This function generalizes the catMaybes
function.
mscatter' :: (MonadPlus m, Foldable t) => m (t b) -> m bSource
Pass through Just
occurrences.
This function generalizes the catMaybes
function.
mcatMaybes :: MonadPlus m => m (Maybe a) -> m aSource
Pass through Just
occurrences.
This function generalizes the catMaybes
function.
mlefts :: MonadPlus m => m (Either a b) -> m aSource
Pass through Left
occurrences.
This function generalizes the lefts
function.
mrights :: MonadPlus m => m (Either a b) -> m bSource
Pass through Right
occurrences.
This function generalizes the rights
function.
mpartitionEithers :: MonadPlus m => m (Either a b) -> (m a, m b)Source
Separate Left
and Right
occurances.
This function generalizes the partitionEithers
function.
Special maps
mmapMaybe :: MonadPlus m => (a -> Maybe b) -> m a -> m bSource
Modify or discard a value.
This function generalizes the mapMaybe
function.
mconcatMap :: MonadPlus m => (a -> [b]) -> m a -> m bSource
Modify and return a number of values.
This function generalizes the concatMap
function.