from-sum: Combinators for working with Maybe and Either

[ bsd3, control, library ] [ Propose Tags ]

Provides many functions for working with Maybe and Either, including canonical fromMaybeM and fromEitherM functions. Please see README.md.


[Skip to Readme]
Versions [faq] 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
Change log CHANGELOG.md
Dependencies base (>=4.6 && <5), transformers [details]
License BSD-3-Clause
Copyright 2016-2019 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 Sat Jan 25 08:03:15 UTC 2020
Distributions Debian:0.2.1.0, LTSHaskell:0.2.1.0, NixOS:0.2.3.0, Stackage:0.2.1.0
Downloads 2772 total (291 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2020-01-25 [all 1 reports]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees


Readme for from-sum-0.2.3.0

[back to package description]

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]