https://github.com/414owen/multi-except
Haskell Applicative Exception type that supports multiple exceptions reported by one computation
https://github.com/414owen/multi-except
applicative haskell
Last synced: 5 months ago
JSON representation
Haskell Applicative Exception type that supports multiple exceptions reported by one computation
- Host: GitHub
- URL: https://github.com/414owen/multi-except
- Owner: 414owen
- License: mit
- Created: 2021-05-11T16:02:07.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2024-04-16T15:44:03.000Z (almost 2 years ago)
- Last Synced: 2025-08-22T13:06:22.786Z (5 months ago)
- Topics: applicative, haskell
- Language: Haskell
- Homepage:
- Size: 122 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# multi-except
[](https://hackage.haskell.org/package/multi-except)
[](https://github.com/414owen/multi-except/actions)
[](https://github.com/414owen/multi-except/blob/master/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
```haskell
{-# 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`](https://hackage.haskell.org/package/base-4.19.0.0/docs/Data-Functor-Compose.html).