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

Add util module #43

Merged
merged 3 commits into from
Aug 3, 2021
Merged

Add util module #43

merged 3 commits into from
Aug 3, 2021

Conversation

patricoferris
Copy link
Contributor

This PR adds a Yaml.Util module providing some common functions for manipulating Yaml.value values or building simple yaml values from OCaml primitives. It mostly follows the naming convention of having f and f_exn the former using the result type and the latter raising an exception. This fixes #40.

@tmcgilchrist
Copy link
Contributor

These functions would be very useful to have.
Added crowbar dependency here #45

@avsm
Copy link
Owner

avsm commented Jul 12, 2021

The functions look good to me, but why put them in a Util module? The functions fit right in the main Yaml module as far as I can tell, as they offer operations over Yaml.value .

@patricoferris
Copy link
Contributor Author

patricoferris commented Jul 12, 2021

I put it in a separate module and included it inside yaml.ml just because I thought yaml.ml was getting a little crowded, I can copy the functions into yaml.ml 👍

@avsm
Copy link
Owner

avsm commented Aug 3, 2021

Let's leave the Util module there, since there's a name clash with the to_string functions. Merging with thanks!

@avsm avsm merged commit d249741 into avsm:master Aug 3, 2021
avsm added a commit that referenced this pull request Aug 3, 2021
avsm added a commit to avsm/opam-repository that referenced this pull request Aug 4, 2021
CHANGES:

* Support Yaml 1.2, and stop advertising Yaml 1.0 support.
  This also updates the vendored libyaml to 0.2.5 (@favonia avsm/ocaml-yaml#37).

* Add a `Yaml.Util` module with a number of useful combinators
  to manipulate `Yaml.value` types, such as retrieving keys and
  values, finding entries and converting to OCaml native
  types (@patricoferris avsm/ocaml-yaml#43)

* Move the sexpression derivers into a separate `Yaml_sexp`
  package (the `yaml-sexp` opam package). This reduces dependencies
  on the main library.  You can still use `Yaml` types in
  `ppx_sexplib_conv` derivers by simply replacing the
  `Yaml.value` (or other type) with `Yaml_sexp.value` which is
  an alias that also includes the Sexp conversion functions in
  its scope. (@alan-j-hu @avsm avsm/ocaml-yaml#46).

* When outputting values, wrap special values like "true" or
  "1.0" in double quotes, so that `Yaml.of_string` will not
  interpret them as a non-string value (@avsm avsm/ocaml-yaml#47).

* Track anchors and mappings in `Yaml.yaml` (but not in the
  `Yaml.value` JSON representation). This also allows non-scalar
   values to be used as keys. (@favonia avsm/ocaml-yaml#38)

* Bump the internal write buffer for stream emission to
  256k from 64k, as people are writing ever-larger Yaml
  files! In the future, this static buffer will be replaced
  by a dynamically growing output buffer but for now needs
  to be set manually.

* The minimum supported OCaml version is now OCaml 4.05.
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.

Provide useful functions in a Util module
3 participants