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: 5 months 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 (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-09-30T07:53:01.000Z (almost 7 years ago)
- Last Synced: 2025-01-27T04:05:09.235Z (6 months 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
[](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.

## 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.