1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
Control.FromSum
===============
[](http://travis-ci.org/cdepillabout/from-sum)
[](https://hackage.haskell.org/package/from-sum)
[](http://stackage.org/lts/package/from-sum)
[](http://stackage.org/nightly/package/from-sum)

This Haskell module exports the `fromEitherM` and `fromMaybeM` convenience
functions.
```haskell
fromMaybeM :: m a -> Maybe a -> m a
fromEitherM :: (e -> m a) -> Either e a -> m a
```
`fromEitherM leftAction eitherValue` is the same as `either leftAction pure
eitherValue`.
`fromMaybeM nothingAction maybeValue` is the same as `maybe nothingAction pure
maybeValue`.
## Usage
```haskell
>>> import Control.FromSum (fromEitherM, fromMaybeM)
>>> fromMaybeM [] $ Just 5
[5]
>>> fromMaybeM [] Nothing
[]
>>> fromEitherM (\s -> [length s]) $ Right 5
[5]
>>> fromEitherM (\s -> [length s]) $ Left "foo"
[3]
```
|