Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lower-level Decoder.t #40

Merged
merged 20 commits into from
Jun 15, 2022
Merged

Lower-level Decoder.t #40

merged 20 commits into from
Jun 15, 2022

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 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