garyb / purescript-codec-argonaut

Bi-directional JSON codecs for argonaut
MIT License
39 stars 16 forks source link

APIs with left out fields don't compose well with APIs using non-purescripty casing #60

Open ysangkok opened 8 months ago

ysangkok commented 8 months ago

If I use camelCase in my codebase, and an API uses snake_case, it seems like I have to use prismaticCodec and create converter functions that convert {field_name :: Foo} to {fieldName :: Foo}.

Using the alternative CA.prop API, I can specify the key name, so there is no issue. But then I can't have left-out fields as there is no pendant to recordPropOptional. Why is there no recordPropOptionalWithCustomKeyName?

garyb commented 8 months ago

propOptional is probably more the missing thing, as recordPropOptionalWithCustomKeyName also implies a missing recordPropWithCustomKeyName, but that's kinda defeating the point of the record-related API, since using it guarantees the codec will roundtrip.

I think propOptional should be easy enough to implement using recordProp vs recordPropOptional as a reference if you want to take a look at that.