Skip to content

Commit f9fb9d7

Browse files
Add option for enums and more instances (#9)
Instances for `Either`, `JSDate`. And some bullshit coverage.
1 parent 0e8a34c commit f9fb9d7

12 files changed

+3528
-45
lines changed

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,4 @@ jobs:
3434
- run: npm install
3535
- run: spago build
3636

37-
- run: spago -x test.dhall test
37+
- run: npm run coverage

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@
66
/.purs*
77
/.psa*
88
/.spago/
9+
/.nyc_output/
10+
/coverage/

.nycrc.json

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"all": true,
3+
"extension": [".purs"],
4+
"include": [ "src/**/*.purs"],
5+
"exclude": [ "src/Yoga/JSON/Generics.purs"],
6+
"excludeAfterRemap": true,
7+
"sourceMap": true
8+
}

README.md

+12-3
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,33 @@ Check out the tests for how to encode/decode increasingly complex types.
2020

2121
## Migrate from `purescript-simple-json`
2222

23-
`purescript-yoga-json` is a drop-in replacement for `purescript-simple-json`. Just change the imports from `Simple.JSON` to `Yoga.JSON`.
23+
`purescript-yoga-json` is almost (read below if you use variants) a drop-in replacement for `purescript-simple-json`. Just change the imports from `Simple.JSON` to `Yoga.JSON`.
2424

25-
## Differences to `simple-json`
25+
## Additions over `simple-json`
2626

2727
### Tuples
2828
There is an inbuilt codec for `Tuple`s thanks to @ursi
29+
`yoga-json` represents tuples as arrays in JSON.
30+
31+
### Tuples
32+
There is an inbuilt codec for `Either`s.
33+
`yoga-json` represents eithers as objects with a `type` and a `value` tag in JSON.
2934

3035
### Generics
3136
It includes @justinwoo's codecs for en- and decoding generics inspired by
3237
[simple-json-generics](https://github.com/justinwoo/purescript-simple-json-generics)
3338

39+
It is possible to customise the representation of enums, tagged sum types, and untagged sum types via options.
40+
3441
### BigInts
3542
It can *read* bigints (if you install `big-integer` as a JS dependency).
3643

3744
### 💣 Cannot write bigints as bigints but only strings
3845
It seems that there is no way to write bigints in JavaScript except for writing your own `JSON.stringify`.
3946

40-
### 💣 The Variant Codec is different
47+
## Differences to `simple-json`
48+
49+
### 💣 Variant codec
4150
If you want to emulate `simple-json`'s format you may use the newtype `TaggedVariant`
4251

4352
```purescript

0 commit comments

Comments
 (0)