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

WriteForeign NonEmptyList? #33

Closed AlexMouton closed 6 years ago

AlexMouton commented 6 years ago

Hey Justin! I'm trying to get errors out of this thing cleanly. what do you think about writeforeign NonEmptyList a, MultipleErrors, Either, F?

Thanks A

justinwoo commented 6 years ago

I think they're awkward since they don't have actual JSON representations (e.g. no actual "List" in JS). I think if you need them, you might do some normal generic record operations (like described in https://qiita.com/kimagure/items/801e1c55d4f8f218f11e). Something like

writeJSON $ myJSON { myList = Array.fromFoldable myList }

Should work fine, or you might throw a Record.modify at it if it doesn't work.

justinwoo commented 6 years ago

Per discussion the other day on #34