purescript-contrib / purescript-argonaut-codecs

JSON serialization and deserialization with Argonaut.
MIT License
48 stars 46 forks source link

Implement typed errors #79

Closed srghma closed 4 years ago

srghma commented 4 years ago

Let's now discuss https://github.com/purescript-contrib/purescript-argonaut-codecs/pull/73 )

thomashoneyman commented 4 years ago

If we went forward with this, ideally we would:

  1. Write up a rationale for why typed errors are an improvement over string errors -- something short, but which lets users know what motivates the change
  2. Make the change to typed errors with the expectation that the error type will be stable in the future (we're not going to keep adding and removing error cases). Using the same error type as purescript-codec-argonaut is a good idea.
  3. Ensure that users can easily recover the string errors from the error type (being able to do lmap errorToString decodeJson is fine), to make their migration easier if they just want to continue using String and avoid rewriting too much code
  4. Write a short migration guide that helps users switch with minimum effort -- ie. examples of switching to use the new error type and examples of how to keep using String if that's what you want.

You don't necessarily need to do all of that as your PR, but I think each of these four should be in place to make the breaking change across quite a big part of the ecosystem.

srghma commented 4 years ago

Ok, I will prepare pr but leave documentation for you

thomashoneyman commented 4 years ago

Closed by #73