Canonical fromMaybeM and fromEitherM functions.

Version on this page:
LTS Haskell 13.25:
Stackage Nightly 2019-06-12:
Latest on Hackage:

See all snapshots from-sum appears in

BSD-3-Clause licensed by Dennis Gosnell
Maintained by

Module documentation for


Build Status Hackage Stackage LTS Stackage Nightly

This Haskell module exports the fromEitherM and fromMaybeM convenience functions.

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.


>>> import Control.FromSum (fromEitherM, fromMaybeM)
>>> fromMaybeM [] $ Just 5
>>> fromMaybeM [] Nothing
>>> fromEitherM (\s -> [length s]) $ Right 5
>>> fromEitherM (\s -> [length s]) $ Left "foo"
Depends on 2 packages:
Used by 1 package:
comments powered byDisqus