monadplus-1.4.3: Haskell98 partial maps and filters over MonadPlus.
Copyright(c) Hans Hoglund 2012
LicenseBSD-style
Maintainerhans@hanshoglund.se
Stabilityexperimental
Portabilitynon-portable (TF,GNTD)
Safe HaskellSafe-Inferred
LanguageHaskell98

Control.Applicative.Alternative

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

Basics

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

Expand

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.