Releases: mlms13/bs-decode
Releases · mlms13/bs-decode
v0.7.0
v0.6.2
v0.6.1
v0.6.0
🚨 Breaking
Decode.fallback
doesn't assume you want to work withfield
s, but you can useDecode.(fallback(field("x", string), "default"))
if you want the old behaviorDecode.Pipeline.fallback
has the same new behavior, but it providesfallbackField
to achieve the old behaviorDecode.ParseError.map
has been removed (it wasn't used internally or documented)- The
Decode.ParseError
variant type now includes aTriedMultiple
constructor. This is only a breaking change if you are matching directly on values of this type.
🐛 Bug fixes
Decode.AsResult.OfStringNel
actually collects multiple errors now
✨ New features
Decode.alt
allows combining decode functions and picking the first successDecode.AsResult.OfStringNel
now includes all of the samemap
,flatMap
, etc functions for decodersDecode.ParseError
is aliased asDecode.AsResult.OfParseError.ParseError
so parse errors can be accessed from an aliased decode module
✔️ Code quality
- Reorganize tests so that
Decode_AsOption
tests decoders pass-vs-fail,Decode_AsResult_*
tests failure reporting - Test coverage has increased to 100%
- Internally, many functions were re-written to use
map
,flatMap
,alt
, etc on the decoders themselves, rather than running the decoders and transforming the output Js.Dict.key
was changed tostring
in interface files for better editor suggestions
v0.5.1
v0.5.0
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 aNonEmptyList
(#28)Decode.ok
has been removed, if you want to construct a decoder that always succeeds (ignoring the JSON input), useDecode.pure
instead.- Decoders that produce
NonEmptyList
s of errors now useRelude.NonEmpty.List
instead of the implementation frombs-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 withoption
andresult
types. (#33)
✨ New stuff
- Decoders (the functions from
Js.Json.t
tooption
orResult.t
) now havemap
,apply
,map2
...map5
, andflatMap
functions, meaning you can transform decoders before actually running them. (#23) D.NonEmptyList
is exposed for all decode modules that return aNonEmptyList
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-openingD.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
Release 0.4.0
It had been too long! Sorry about that! Lots of great work went into this release:
- Add
oneOf
to attempt multiple decoders before failing - Decode directly into
Js.Dict.t
with thedict
decoder - Decode dates from floats or ISO-8601 strings
- Decode directly into Reason variants without having to extend
DecodeBase
- Use
at
in thePipeline
to dig through nested JSON objects - Breaking: deprecate
int
andfloat
to avoid compiler complaints with localopen
s. UseintFromNumber
andfloatFromNumber
now instead.
Additionally, lots of work is going in to docs and improving the examples. The docs site isn't up just yet, but it should be shortly.
Decode zero as int
There was a divide-by-zero bug when trying to decode 0
as an int... it's fixed now.
v0.3.1 interface files
ResultUtil
is now more consistent betweenOfParseError
andOfStringNel
- Interface files! No longer will editor suggestions and compiler errors talk about
BsAbstract.Option.Monad.t
v0.3.0 now with booleans and a cleaner API
decodeString
is now juststring
; same forfield
,optional
,int
, and everything else- we can now decode booleans (oops, quite the oversight, thanks to @johnhaley81 for the fix!)
- the arguments to
Pipeline.run
are now flipped, meaning you can chain|> run(json)
using the normal pipe instead of the fast pipe (thanks @gavacho!)