from-sum: Canonical fromMaybeM and fromEitherM functions.

[ bsd3, control, library ] [ Propose Tags ]

Please see README.md


[Skip to Readme]
Versions 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.2.0.0, 0.2.1.0
Dependencies base (>=4.6 && <5), mtl [details]
License BSD-3-Clause
Copyright 2016 Dennis Gosnell
Author Dennis Gosnell
Maintainer cdep.illabout@gmail.com
Category Control
Home page https://github.com/cdepillabout/from-sum
Source repo head: git clone git@github.com:cdepillabout/from-sum.git
Uploaded by cdepillabout at Thu Nov 17 07:29:40 UTC 2016
Distributions LTSHaskell:0.2.1.0, NixOS:0.2.1.0, Stackage:0.2.1.0, openSUSE:0.2.1.0
Downloads 967 total (10 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by rule of succession]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-11-17 [all 1 reports]
Hackage Matrix CI

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for from-sum-0.2.1.0

[back to package description]

Control.FromSum

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.

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]