from-sum: Canonical fromMaybeM and fromEitherM functions.

[ bsd3, control, library ] [ Propose Tags ] [ Report a vulnerability ]

Please see README.md


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.2.0.0, 0.2.1.0, 0.2.2.0, 0.2.3.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 2016-11-17T07:29:40Z
Distributions Debian:0.2.3.0, LTSHaskell:0.2.3.0, NixOS:0.2.3.0, Stackage:0.2.3.0
Reverse Dependencies 2 direct, 2 indirect [details]
Downloads 5397 total (47 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-11-17 [all 1 reports]

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]