purescript-foreign-generic icon indicating copy to clipboard operation
purescript-foreign-generic copied to clipboard

Add `Either` and `Maybe` de/encode instances

Open csicar opened this issue 5 years ago • 3 comments

This PR adds Encode and Decode instances for Either and Maybe and Set #5

The encodings are:

Left 1 <=> {"Left": 1}

Tuple 1 2 <=> [1, 2]

fromFoldable [1, 2, 3] <=> [1, 2, 3]

Decoding [1, 1, 2, 3] as a Set will fail with an error, because of the duplicate element

csicar avatar Sep 05 '20 14:09 csicar

Will this address the following issues?

https://try.purescript.org/?gist=7e51897c612c1ff13a6f1aad7b71e5b4

paulyoung avatar Oct 22 '20 01:10 paulyoung

Actually, I think this would: https://github.com/purescript/purescript-generics-rep/pull/34

paulyoung avatar Oct 22 '20 01:10 paulyoung

tnx, @csicar, I have merged Your commit in https://github.com/purescript-open-community/purescript-open-foreign-generic

already published https://pursuit.purescript.org/packages/purescript-open-foreign-generic/11.0.3 (can be used by just adding open- prefix in spago.yaml)

will send You an invite to join https://github.com/purescript-open-community

srghma avatar Sep 25 '24 03:09 srghma