Skip to content

v0.5.0

Choose a tag to compare

@mlms13 mlms13 released this 13 May 17:21

This release focuses on cleaning up our public API and our internal tooling. Additionally, decoders are easier to compose, so you should be able to do more mapping/flatMapping on the decode functions directly (before running the decoders), instead of needing to transform the output (after running the decoders).

🚨 Breaking

  • oneOf now takes a single decoder, followed by a list of decoders instead of requiring you to construct a NonEmptyList (#28)
  • Decode.ok has been removed, if you want to construct a decoder that always succeeds (ignoring the JSON input), use Decode.pure instead.
  • Decoders that produce NonEmptyLists of errors now use Relude.NonEmpty.List instead of the implementation from bs-nonempty due to more active maintenance and a broader collection of helper functions
  • D.ResultUtils is no longer part of the public interface. Decode functions themselves are more easily composable (see "New stuff" below), so there's less need to transform the output after decoding. Plus better libraries exist if you want to work with option and result types. (#33)

✨ New stuff

  • Decoders (the functions from Js.Json.t to option or Result.t) now have map, apply, map2...map5, and flatMap functions, meaning you can transform decoders before actually running them. (#23)
  • D.NonEmptyList is exposed for all decode modules that return a NonEmptyList of errors. This means you can do basic operations with the errors without bringing in an additional library (#24)
  • D.Pipeline aliases most of the base decoders (e.g. string, intFromNumber, etc), so locally-opening D.Pipeline should get you everything you need (#27)

✔️ Internal cleanup

  • Internal use of infix functions has been greatly reduced to improve code clarity
  • Tests have fewer global opens and fewer aliased functions