justinwoo / purescript-simple-json

A simple Purescript JSON library that uses types automatically
http://purescript-simple-json.readthedocs.io
MIT License
133 stars 45 forks source link

Creating enumWriteForeign? #68

Closed Cmdv closed 4 years ago

Cmdv commented 4 years ago

I've created an enumReadForeign from reading the docs but I'm wondering if I would have to do something similar to account for the from or is there a simpler way?

justinwoo commented 4 years ago

yeah i think you're going to be stuck with writing it out manually, unless you come up with some kind of bidirectional thing. but this is also where i ended up using my other library for converting sums to variant and such to use the inferred instances: https://github.com/justinwoo/purescript-kishimen#usage

justinwoo commented 4 years ago

probably this should be mentioned somewhere in the docs but im a bit too lazy

Cmdv commented 4 years ago

hahaha that's all good can't write everything. Ah nice you have genericSumToVariant that's perfect was more interested in getting type safety for these sum types when throwing them to and from an external API. Thank 👍

Cmdv commented 4 years ago

oh a side note I could do something like you did here

https://github.com/adamczykm/purescript-sentry-raven/blob/fd82dce103912cbd404f04932f3bd523e3f88307/src/SentryRaven/Breadcrumb.purs#L34-L39