{"id":15061194,"url":"https://github.com/ahrefs/melange-atdgen-codec-runtime","last_synced_at":"2026-01-24T10:01:16.658Z","repository":{"id":33118502,"uuid":"146442358","full_name":"ahrefs/melange-atdgen-codec-runtime","owner":"ahrefs","description":null,"archived":false,"fork":false,"pushed_at":"2025-11-17T16:52:25.000Z","size":860,"stargazers_count":30,"open_issues_count":6,"forks_count":15,"subscribers_count":29,"default_branch":"master","last_synced_at":"2025-12-01T08:22:34.592Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ahrefs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-28T12:12:58.000Z","updated_at":"2025-03-14T12:30:02.000Z","dependencies_parsed_at":"2023-10-23T16:32:02.529Z","dependency_job_id":"ecb85931-4914-4d1f-adf3-ad7b2a58279d","html_url":"https://github.com/ahrefs/melange-atdgen-codec-runtime","commit_stats":null,"previous_names":["ahrefs/bs-atdgen-codec-runtime"],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/ahrefs/melange-atdgen-codec-runtime","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fmelange-atdgen-codec-runtime","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fmelange-atdgen-codec-runtime/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fmelange-atdgen-codec-runtime/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fmelange-atdgen-codec-runtime/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ahrefs","download_url":"https://codeload.github.com/ahrefs/melange-atdgen-codec-runtime/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ahrefs%2Fmelange-atdgen-codec-runtime/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28724374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T08:27:05.734Z","status":"ssl_error","status_checked_at":"2026-01-24T08:27:01.197Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-09-24T23:11:31.670Z","updated_at":"2026-01-24T10:01:16.571Z","avatar_url":"https://github.com/ahrefs.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"# melange-atdgen-codec-runtime\n\n`melange-atdgen-codec-runtime` is a Melange runtime for\n[atdgen](https://github.com/ahrefs/atd). It is based on the `Js.Json.t`\nprovided by Melange and combinators of\n[melange-json](https://github.com/melange-community/melange-json).\n\n## Installation\n\nInstall [opam](https://opam.ocaml.org/) package manager.\n\nThen:\n\n```bash\nopam install melange-atdgen-codec-runtime\n```\n\n## Usage\n\nTo generate `ml` files from `atd` ones, add a couple of rules to your `dune` file:\n\n```clojure\n(rule\n (targets test_mel.ml test_mel.mli)\n (deps test.atd)\n (action\n  (run atdgen -mel %{deps})))\n\n(rule\n (targets test_t.ml test_t.mli)\n (deps test.atd)\n (action\n  (run atdgen -t %{deps})))\n```\n\nYou can see examples in [the tests](./src/__tests__/dune) or [the example](./example/src/dune).\n\nTo use the generated modules, you will need to include the runtime library in\nyour project. To do so, add  `melange-atdgen-codec-runtime` to the `libraries`\nfield in your `dune` file:\n\n```clojure\n; ...\n  (libraries melange-atdgen-codec-runtime)\n; ...\n```\n\nTo write atd type definitions, please have a look at the [great atd\ndocumentation](https://atd.readthedocs.io/en/latest/).\n\n## Simple example\n\nReason code to query and deserialize the response of a REST API. It\nrequires [melange-fetch](https://github.com/melange-community/melange-fetch).\n\n```ocaml\nlet get = (url, decode) =\u003e\n  Js.Promise.(\n    Fetch.fetchWithInit(\n      url,\n      Fetch.RequestInit.make(~method_=Get, ()),\n    )\n    |\u003e then_(Fetch.Response.json)\n    |\u003e then_(json =\u003e json |\u003e decode |\u003e resolve)\n  );\n\nlet v: Meetup_t.events =\n  get(\n    \"http://localhost:8000/events\",\n    Atdgen_codec_runtime.Decode.decode(Meetup_mel.read_events),\n  );\n```\n\n## Full example\n\nThe [example](example) directory contains a full example of a simple\ncli to read and write data in a JSON file.\n\nFor a complete introduction from atdgen installation to json\nmanipulation, please refer to [Getting started with ATD and\nMelange](https://tech.ahrefs.com/getting-started-with-atd-and-melange-1f3a14004081).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahrefs%2Fmelange-atdgen-codec-runtime","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fahrefs%2Fmelange-atdgen-codec-runtime","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fahrefs%2Fmelange-atdgen-codec-runtime/lists"}