BSD-3-Clause licensed by Dennis Gosnell

Module documentation for 0.2.2.0

This version can be pinned in stack with:from-sum-0.2.2.0@sha256:7ddedfd4602adc2a6bdd6a2ad72de930a2598abc4422a6aeaf84225a729f7f78,1261

Control.FromSum

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.

Usage

>>> 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]

Changes

0.2.2.0

  • Added new functions maybeToEither, maybeToEitherOr, and eitherToMaybe for converting between Maybe and Either. #1
Depends on 2 packages(full list with versions):
Used by 1 package in lts-14.20(full list with versions):