{"id":15647883,"url":"https://github.com/hannesm/gmap","last_synced_at":"2025-04-30T13:40:30.041Z","repository":{"id":65612893,"uuid":"137601890","full_name":"hannesm/gmap","owner":"hannesm","description":"heterogenous Map over a GADT","archived":false,"fork":false,"pushed_at":"2024-12-17T17:02:41.000Z","size":47,"stargazers_count":42,"open_issues_count":4,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-02-25T08:08:41.666Z","etag":null,"topics":["data-structure","gadt","heterogeneous","map","ocaml"],"latest_commit_sha":null,"homepage":null,"language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hannesm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-06-16T18:28:26.000Z","updated_at":"2024-12-17T17:02:47.000Z","dependencies_parsed_at":"2023-01-31T19:31:17.932Z","dependency_job_id":null,"html_url":"https://github.com/hannesm/gmap","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannesm%2Fgmap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannesm%2Fgmap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannesm%2Fgmap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hannesm%2Fgmap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hannesm","download_url":"https://codeload.github.com/hannesm/gmap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242661652,"owners_count":20165329,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["data-structure","gadt","heterogeneous","map","ocaml"],"created_at":"2024-10-03T12:21:49.410Z","updated_at":"2025-03-09T07:32:07.572Z","avatar_url":"https://github.com/hannesm.png","language":"OCaml","readme":"## Gmap - heterogenous maps over a GADT\n\n%%VERSION%%\n\nGmap exposes the functor `Make` which takes a key type (a\n[GADT](https://en.wikipedia.org/wiki/Generalized_algebraic_data_type) 'a key)\nand outputs a type-safe Map where each 'a key is associated with a 'a value.\nThis removes the need for additional packing.  It uses OCaml's stdlib\n[Map](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Map.html) data\nstructure.\n\n```OCaml\ntype _ key =\n  | I : int key\n  | S : string key\n\nmodule K = struct\n  type 'a t = 'a key\n\n  let compare : type a b. a t -\u003e b t -\u003e (a, b) Gmap.Order.t = fun t t' -\u003e\n    let open Gmap.Order in\n    match t, t' with\n    | I, I -\u003e Eq | I, _ -\u003e Lt | _, I -\u003e Gt\n    | S, S -\u003e Eq\nend\n\nmodule M = Gmap.Make(K)\n\n\nlet () =\n  let m = M.empty in\n  ...\n  match M.find I m with\n  | Some x -\u003e Printf.printf \"got %d\\n\" x\n  | None -\u003e Printf.printf \"found nothing\\n\"\n```\n\nThis is already an exhaustive pattern match: there is no need for another case\n(for the constructor `S`) since the type system knows that looking for `I` will\nresult in an `int`.\n\nMotivation came from parsing of protocols which usually specify optional values\nand extensions via a tag-length-value (TLV) mechanism: for a given tag the\nstructure of value is different - see for example IP options, TCP options, DNS\nresource records, TLS hello extensions, etc.\n\nDiscussing this problem with Justus Matthiesen during summer 2017, we came up\nwith this design. Its main difference to Daniel C. Bünzli's\n[hmap](http://erratique.ch/software/hmap) is that in gmap the key-value GADT\ntype must be provided when instantiating the functor.  In hmap, keys are created\ndynamically.\n\n## Documentation\n\n[![Build Status](https://travis-ci.org/hannesm/gmap.svg?branch=master)](https://travis-ci.org/hannesm/gmap)\n\n[API documentation](https://hannesm.github.io/gmap/doc/) is available online.\n\n## Installation\n\nYou need [opam](https://opam.ocaml.org) installed on your system.  The command\n\n`opam install gmap`\n\nwill install this library.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhannesm%2Fgmap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhannesm%2Fgmap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhannesm%2Fgmap/lists"}