Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/justinwoo/purescript-bibimbap
The flip side of Chirashi, simply storing sum type values and retrieving them by using the constructor name as a test value, by using Generic.Rep to get constructor names from a sum type definition.
https://github.com/justinwoo/purescript-bibimbap
error generics-rep purescript
Last synced: 15 days ago
JSON representation
The flip side of Chirashi, simply storing sum type values and retrieving them by using the constructor name as a test value, by using Generic.Rep to get constructor names from a sum type definition.
- Host: GitHub
- URL: https://github.com/justinwoo/purescript-bibimbap
- Owner: justinwoo
- License: mit
- Created: 2018-09-30T07:49:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-30T07:53:01.000Z (over 6 years ago)
- Last Synced: 2024-12-07T04:08:25.113Z (about 1 month ago)
- Topics: error, generics-rep, purescript
- Language: PureScript
- Homepage:
- Size: 3.91 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Purescript-Bibimbap
[![Build Status](https://travis-ci.org/justinwoo/purescript-bibimbap.svg?branch=master)](https://travis-ci.org/justinwoo/purescript-bibimbap)
[Docs on Pursuit](https://pursuit.purescript.org/packages/purescript-bibimbap)
The flip side of [Chirashi](https://github.com/justinwoo/purescript-chirashi), simply storing sum type values and retrieving them by using the constructor name as a test value, by using `Generic.Rep` to get constructor names from a sum type definition.
Works by subclassing Error.
![](https://i.imgur.com/LG0UqbA.jpg)
## Usage
```purs
data ErrorGenericSum
= Apple
| Banana { info :: String }
| Cherry Int Int Int
derive instance genericErrorGenericSum :: GR.Generic ErrorGenericSum _main = do
let
knownGenericSum :: ErrorGenericSum
knownGenericSum = Banana { info: "hello" }
knownError = Bibimbap.mkGenericSumError knownGenericSum
resultKnownError = Bibimbap.readGenericSum knownErrorAssert.assertEqual
{ expected: Just knownGenericSum
, actual: resultKnownError
}
```See tests for more examples.