BSD-3-Clause licensed by Dennis Gosnell
Maintained by [email protected]
This version can be pinned in stack with:from-sum-,1321

Module documentation for

Depends on 2 packages(full list with versions):
Used by 1 package in lts-22.26(full list with versions):


Build Status Hackage Stackage LTS Stackage Nightly BSD3 license

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"


  • Add functions collapseErrExceptT, liftEitherExceptT, fromEitherExceptT, fromEitherOrExceptT, fromEitherMExceptT, fromEitherOrMExceptT, fromMaybeExceptT, fromMaybeOrExceptT, fromMaybeMExceptT, fromMaybeOrMExceptT, guardExceptT, and guardMExceptT. These functions help convert Maybe, Either, and Bool to ExceptT. #2

  • Added new functions maybeToEither, maybeToEitherOr, and eitherToMaybe for converting between Maybe and Either. #1