| Safe Haskell | Safe |
|---|
Eta.Classes.Monad
Description
The Monad type class defines that a type
can have an flatMap operation which can be used
to sequence actions over the same type.
All types that implement Monad must implement
Applicative.
The List, Maybe, and IO types are examples of
instances of Monad.
>>>flatMap (\x -> [1 .. x]) [1, 2, 3][1,1,2,1,2,3]
Mnemonic: Sequenceable
Documentation
class Applicative m => Monad m where #
Minimal complete definition
Instances
| Monad [] | |
| Monad Maybe | |
| Monad IO | |
| Monad U1 | |
| Monad Par1 | |
| Monad Sum | |
| Monad Product | |
| Monad Last | |
| Monad First | |
| Monad Dual | |
| Monad ((->) r) | |
| Monad (Either e) | |
| Monad f => Monad (Rec1 f) | |
| Monoid a => Monad ((,) a) | |
| Monad m => Monad (WrappedMonad m) | |
| Monad (Proxy *) | |
| (Monad f, Monad g) => Monad ((:*:) f g) | |
| Monad f => Monad (Alt * f) | |
| Monad f => Monad (M1 i c f) | |
(|>>) :: Monad m => m a -> (a -> m b) -> m b #
Flatmaps the function of the right over the Monad of the left
>> readFile "data.txt" |>> printLine "This is some data stored in data.txt"
(<<|) :: Monad m => (a -> m b) -> m a -> m b #
Flatmaps the function of the left over the Monad of the left
>> printLine <<| readFile "data.txt" "This is some data stored in data.txt"
Creates a new function that can be flatmapped by composing two functions:
>> readAndPrint = readFile >=> printLine >> readAndPrint "data.txt" "This is some data stored in data.txt"
Sometimes referred as Kleisli composition
Inverted '(>=>)'