| Copyright | (c) Hans Hoglund 2012 |
|---|---|
| License | BSD-style |
| Maintainer | hans@hanshoglund.se |
| Stability | experimental |
| Portability | non-portable (TF,GNTD) |
| Safe Haskell | Safe-Inferred |
| Language | Haskell98 |
Control.Applicative.Alternative
Contents
Description
Partial maps and filters over Alternative instances.
This is considerably weaker than MonadPlus, as we have no possibility of removing
intermediate structure, as in mcatMaybes.
Synopsis
- module Control.Applicative
- asum :: (Foldable t, Alternative f) => t (f a) -> f a
- afold :: (Alternative f, Foldable t) => t a -> f a
- afromList :: Alternative f => [a] -> f a
- afromMaybe :: Alternative f => Maybe a -> f a
Basics
module Control.Applicative
asum :: (Foldable t, Alternative f) => t (f a) -> f a #
The sum of a collection of actions, generalizing concat.
asum is just like msum, but generalised to Alternative.
Examples
Basic usage:
>>>asum [Just "Hello", Nothing, Just "World"]Just "Hello"
Constructing
afold :: (Alternative f, Foldable t) => t a -> f a Source #
Fold a value into an arbitrary MonadPlus type.
This function generalizes the toList function.
afromList :: Alternative f => [a] -> f a Source #
This function generalizes the listToMaybe function.
afromMaybe :: Alternative f => Maybe a -> f a Source #
Translate maybe to an arbitrary Alternative type.
This function generalizes the maybeToList function.