multi-except: Multiple Exceptions

[ exceptions, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Succeed, or return one or more errors.


[Skip to Readme]

library multi-except

library multi-except:semigroupoid-instances

Modules

[Index] [Quick Jump]

  • Control
    • Applicative
      • MultiExcept
        • Control.Applicative.MultiExcept.Alt

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.0.0, 0.1.1.0, 0.1.2.0, 0.1.3.0, 0.1.4.0, 0.2.0.0, 0.2.1.0, 0.3.0.0, 1.0.0, 2.0.0
Change log CHANGELOG.md
Dependencies base (>=4.0 && <5), multi-except, semigroupoids (>=1 && <7) [details]
Tested with ghc ==9.6.2, ghc ==9.4.5, ghc ==9.2.8, ghc ==9.0.2, ghc ==8.10.7, ghc ==8.8.4, ghc ==8.6.5, ghc ==8.4.4, ghc ==8.2.2, ghc ==8.0.2, ghc ==7.10.3, ghc ==7.8.4, ghc ==7.6.3, ghc ==7.4.2, ghc ==7.2.2, ghc ==7.0.4
License MIT
Author Owen Shepherd
Maintainer owen@owen.cafe
Category Exceptions
Home page https://github.com/414owen/multi-except
Source repo head: git clone https://github.com/414owen/multi-except.git
Uploaded by 414owen at 2024-01-03T15:04:34Z
Distributions NixOS:2.0.0
Downloads 1114 total (10 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs uploaded by user
Build status unknown [no reports yet]

Readme for multi-except-2.0.0

[back to package description]

multi-except

Hackage version CI Status GitHub License

multi-except - succeed, or return one or more errors

Adding the dependency

-- in your cabal file
  -- Add the main package (only depends on base!)
  , multi-except
  -- For the Alt instance (depends on semigroupoids)
  , multi-except:semigroupoid-instances

Usage

{-# LANGUAGE ApplicativeDo #-}

import Control.Applicative.MultiExcept

errors :: MultiExcept String (Int, Int, Int)
errors = do
  a <- throwError "no monad instance"
  b <- pure 12
  c <- throwError "i am scared"
  pure (a, b, c)

-- errors: Errors ["no monad instance", "i am scared"]

The use of ApplicativeDo is significant and necessary for using MultiExcept with do notation.

MultiExcept is not a Monad, only an Applicative, so a few constraints apply, such as not being able to determine the structure of the rest of the computation based on a previously do-bound value. If the previous sentence was confusing, then you might want to consider using a writer monad instead.

To compose with other applicative effects, you can use Data.Functor.Compose.