purescript-codec-argonaut icon indicating copy to clipboard operation
purescript-codec-argonaut copied to clipboard

variantMatch function -> don't use either to differentiate between parsers and nullary constructors

Open srghma opened this issue 4 years ago • 2 comments

In docs

The fields in the record passed to CAV.variantMatch correspond with the variant constructors. Each one accepts an Either carrying either a codec or a static value - Right with a codec for when there's a value that needs encoding for the constructor, Left with a static value for nullary constructors.

It's better to make it accept

data VariantMatchCodecType a b = Codec a | Nullary b

srghma avatar Dec 14 '19 06:12 srghma

Why's that? Also, the instructor variable is undefined here, and I'm not sure what the b is for either.

garyb avatar Dec 14 '19 13:12 garyb

Also, the instructor variable is undefined here

oh, sorry, typo, updated

Why's that?

it's the same as Either, but more descriptive

Codec is better than Left, Nullary is better than Right

srghma avatar Dec 14 '19 13:12 srghma