Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinwoo/purescript-chirashi
An easy way to work with Errors by inserting a Variant, and reading it out later.
https://github.com/justinwoo/purescript-chirashi
error purescript variant
Last synced: about 2 months ago
JSON representation
An easy way to work with Errors by inserting a Variant, and reading it out later.
- Host: GitHub
- URL: https://github.com/justinwoo/purescript-chirashi
- Owner: justinwoo
- License: mit
- Created: 2018-09-29T13:26:35.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2019-05-30T10:04:36.000Z (over 5 years ago)
- Last Synced: 2024-10-11T22:28:00.774Z (2 months ago)
- Topics: error, purescript, variant
- Language: PureScript
- Homepage:
- Size: 4.88 KB
- Stars: 4
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Purescript-Chirashi
[![Build Status](https://travis-ci.org/justinwoo/purescript-chirashi.svg?branch=master)](https://travis-ci.org/justinwoo/purescript-chirashi)
[Docs on Pursuit](https://pursuit.purescript.org/packages/purescript-chirashi)
An easy way to work with `Error`s by inserting a `Variant`, and reading it out later.
Works by subclassing Error.
![](https://i.imgur.com/468wLLl.jpg)
## Usage
```purs
type ErrorVariant = Variant
( apple :: String
, banana :: { info :: String }
, cherry :: Unit
)main = do
let
knownVariant :: ErrorVariant
knownVariant = Variant.inj (SProxy :: SProxy "banana") { info: "hello" }
knownError = Chirashi.mkVariantError knownVariant
resultKnownError = Chirashi.readVariant knownErrorAssert.assertEqual
{ expected: Just knownVariant
, actual: resultKnownError
}
```See tests for more examples.
## Other links
For more ideas on what you could do with this library, see [Ochadzuke](https://github.com/justinwoo/purescript-ochadzuke#usage).