from-sum: Combinators for working with Maybe and Either

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

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


[Skip to Readme]

Modules

[Index] [Quick Jump]

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
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 2020-01-25T08:03:15Z
Distributions Debian:0.2.3.0, LTSHaskell:0.2.3.0, NixOS:0.2.3.0, Stackage:0.2.3.0
Reverse Dependencies 3 direct, 2 indirect [details]
Downloads 5401 total (49 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 2020-01-25 [all 1 reports]

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]