purescript-contrib/purescript-argonaut-codecs

Instance for NonEmptyArray?

JamieBallingall opened this issue · 2 comments

We have an instances of EncodeJson and DecodeJson for NonEmpty Array but not for NonEmptyArray. Is there a reason for that?

If not, I'd be happy to take a shot at implementing, with two minor points:

  1. The logical names for those instances (encodeJsonNonEmptyArray and decodeJsonNonEmptyArray) are already in use. I propose renaming the existing ones to encodeJsonNonEmpty_Array and decodeJsonNonEmpty_Array. Would that break anything?
  2. There was some discussion in #25 about implementing encodeJsonNonEmptyFoldable and decodeJsonNonEmptyFoldable. That doesn't seem to have happened. Was there a reason it was avoided or did it just fall off the radar?

@JamieBallingall Those instances would be welcome!

I'm not sure what to name them, but as far as I'm aware changing the instance names should not break anything (there would have to be something relying on the names in the generated code, which is highly unlikely). Perhaps @garyb has input on using _ in the new names.

I think #25 simply fell off the radar. It's worth being careful about ensuring that various Foldable structures all turn into reasonable JSON, so if / when a PR is opened I'd like to test a few common structures, but it ought to be doable!

garyb commented

I wouldn't really have a problem changing the instance names as suggested. If you're being super picky it's a breaking change, in case someone is using them from JS, but aside from that not being a recommended practice anyway I think it's very unlikely.