Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=cadf9c13ddcffe11dd0c6712925d49bbef61c9bc4d5b4bfce4d0628628ecaabc
sha512=88e16fc3271cc2605b0023912685814fc5050dd2cdd67436329c89b60001ef2153d6eab7496a96a2e4fc187b66cde9c790a47afb5d0daacd16fa75780db2b73f
Description
A Melange runtime for atdgen, based on the Js.Json.t type provided by Melange and the combinators from melange-json
Added to opam-repository:
README
melange-atdgen-codec-runtime
melange-atdgen-codec-runtime is a Melange runtime for atdgen. It is based on the Js.Json.t provided by Melange and combinators of melange-json.
Installation
Install opam package manager.
Then:
opam install melange-atdgen-codec-runtimeUsage
To generate ml files from atd ones, add a couple of rules to your dune file:
(rule
(targets test_mel.ml test_mel.mli)
(deps test.atd)
(action
(run atdgen -mel %{deps})))
(rule
(targets test_t.ml test_t.mli)
(deps test.atd)
(action
(run atdgen -t %{deps})))You can see examples in the tests or the example.
To use the generated modules, you will need to include the runtime library in your project. To do so, add melange-atdgen-codec-runtime to the libraries field in your dune file:
; ...
(libraries melange-atdgen-codec-runtime)
; ...To write atd type definitions, please have a look at the great atd documentation.
Simple example
Reason code to query and deserialize the response of a REST API. It requires melange-fetch.
let get = (url, decode) =>
Js.Promise.(
Fetch.fetchWithInit(
url,
Fetch.RequestInit.make(~method_=Get, ()),
)
|> then_(Fetch.Response.json)
|> then_(json => json |> decode |> resolve)
);
let v: Meetup_t.events =
get(
"http://localhost:8000/events",
Atdgen_codec_runtime.Decode.decode(Meetup_mel.read_events),
);Full example
The example directory contains a full example of a simple cli to read and write data in a JSON file.
For a complete introduction from atdgen installation to json manipulation, please refer to Getting started with ATD and Melange.
Dependencies (6)
Dev Dependencies (4)
-
odoc
with-doc -
opam-check-npm-deps
with-test -
reason
with-test -
melange-jest
with-test
Optional Dependencies
None
Used by
None
Conflicts
None
Build status
Results of building melange-atdgen-codec-runtime with each compiler on check.ci.ocaml.org, run of against opam-repository 8a77e58. All results for this package.
Each result links to its build log. To keep crawlers from overloading the site, build logs require a GitHub sign-in (see ocurrent/opam-health-check). On your first log, GitHub asks you to “Authorize opam-health-check”, the OCurrent app that runs these checks; it sees only your public profile, not your repositories. The sign-in lasts 30 days.
| Version | OCaml 4.11 | OCaml 4.14 | OCaml 5.2 | OCaml 5.4 | OCaml 5.5 |
|---|---|---|---|---|---|
| 3.0.1 (this version) | n/a | good | good | good | good |
- good Package successfully built
- partial One of the dependencies failed to build
- bad Package failed to build
- n/a Package is not available in this environment
- internal Internal failure