Skip to content

Conversation

mattjbray
Copy link
Owner

@mattjbray mattjbray commented Jun 28, 2021

Refactors decoders around a lower-level Decoder.t type:

type ('i, 'o) t = 'i -> ('o, 'i Error.t) result

This new Decoder module could be useful outside of the JSON-like decoders this library already provides; anywhere you need to convert from a representation 'i to a representation 'o, where there is a possibility of error 'i Error.t.

An example is decoding expressions returned by the BigQuery API in ocaml-gcloud:

The existing JSON-like decoders become, for example:

(* Decoders_yojson.Basic.Decode *)
type 'a t = (Yojson.Basic.t, 'a) Decoder.t

TODO:

  • let-ops shims
  • bucklescript compat
  • decoder.mli
  • error.mli

@mattjbray mattjbray force-pushed the extract-decoder branch 2 times, most recently from 12c1785 to 570833f Compare June 28, 2021 13:19
@mattjbray mattjbray marked this pull request as ready for review June 15, 2022 10:25
@mattjbray mattjbray merged commit 10fe36f into master Jun 15, 2022
@mattjbray mattjbray deleted the extract-decoder branch June 15, 2022 10:46
mattjbray added a commit to mattjbray/opam-repository that referenced this pull request Aug 8, 2022
…sgpck, decoders-jsonm, decoders-jsonaf, decoders-ezxmlm, decoders-ezjsonm, decoders-cbor and decoders-bencode (1.0.0)

CHANGES:

* Extract and expose `Decoder.t`, useful for "decoding" things outside of the JSON family (mattjbray/ocaml-decoders#40, @mattjbray).
* Add `Decoders.Xml.S` to `decoders`, create `decoders-ezxmlm`, and add `Decoders_bs_xml` to `bs-decoders` (mattjbray/ocaml-decoders#49, @mattjbray).
* BREAKING: namespace `bs-decoders` modules under `Decoders`. To upgrade,
  replace `Decoders_bs` with `Decoders.Bs_json` (mattjbray/ocaml-decoders#49, @mattjbray).
* Add `decoders-jsonaf` (mattjbray/ocaml-decoders#50, @dvmitrv).
mattjbray added a commit to mattjbray/opam-repository that referenced this pull request Aug 9, 2022
…sgpck, decoders-jsonm, decoders-jsonaf, decoders-ezxmlm, decoders-ezjsonm, decoders-cbor and decoders-bencode (1.0.0)

CHANGES:

* Extract and expose `Decoder.t`, useful for "decoding" things outside of the JSON family (mattjbray/ocaml-decoders#40, @mattjbray).
* Add `Decoders.Xml.S` to `decoders`, create `decoders-ezxmlm`, and add `Decoders_bs_xml` to `bs-decoders` (mattjbray/ocaml-decoders#49, @mattjbray).
* BREAKING: namespace `bs-decoders` modules under `Decoders`. To upgrade,
  replace `Decoders_bs` with `Decoders.Bs_json` (mattjbray/ocaml-decoders#49, @mattjbray).
* Add `decoders-jsonaf` (mattjbray/ocaml-decoders#50, @dvmitrv).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant