this repo has no description
1opam-version: "2.0" 2maintainer: "Hannes Mehnert <hannes@mehnert.org>" 3authors: ["Hannes Mehnert <hannes@mehnert.org>"] 4homepage: "https://github.com/hannesm/gmap" 5doc: "https://hannesm.github.io/gmap/doc" 6dev-repo: "git+https://github.com/hannesm/gmap.git" 7bug-reports: "https://github.com/hannesm/gmap/issues" 8license: "ISC" 9depends: [ 10 "ocaml" {>= "4.04.2"} 11 "ocamlfind" {build} 12 "ocamlbuild" {build} 13 "topkg" {build} 14 "fmt" 15] 16build: [ 17 [ "ocaml" "pkg/pkg.ml" "build" "--pinned" "%{pinned}%" "--tests" "false" ] 18] 19synopsis: "Heterogenous maps over a GADT" 20description: """ 21Gmap exposes the functor `Make` which takes a key type (a GADT 'a key) and 22outputs a type-safe Map where each 'a key is associated with a 'a value. This 23removes the need for additional packing. 24 25```OCaml 26type _ k = 27 | A : int k 28 | B : string k 29 30module K = struct 31 type 'a t = 'a k 32 33 let compare : type a b. a t -> b t -> (a, b) Gmap.Order.t = fun t t' -> 34 let open Gmap.Order in 35 match t, t' with 36 | A, A -> Eq | A, _ -> Lt | _, A -> Gt 37 | B, B -> Eq 38 39 let pp : type a. Format.formatter -> a t -> a -> unit = fun ppf t v -> 40 match t, v with 41 | A, x -> Fmt.pf ppf "A %d" x 42 | B, s -> Fmt.pf ppf "B %s" s 43end 44 45module M = Gmap.Make(K) 46 47 48let () = 49 let m = M.empty in 50 ... 51 match M.find A m with 52 | Some x -> Printf.printf "got %d\\n" x 53 | None -> Printf.printf "found nothing\\n" 54``` 55 56This is already an exhaustive pattern match: there is no need for another case 57(for the constructor `B`) since the type system knows that looking for `A` will 58result in an `int`. 59 60Motivation came from parsing of protocols which usually specify optional values 61and extensions via a tag-length-value (TLV) mechanism: for a given tag the 62structure of value is different - see for example IP options, TCP options, DNS 63resource records, TLS hello extensions, etc. 64 65Discussing this problem with Justus Matthiesen, we came up with this design. Its 66main difference to Daniel C. Bünzli's [hmap](http://erratique.ch/software/hmap) 67is that in gmap the key-value GADT type must be provided when instantiating the 68functor. In hmap, keys are created dynamically.""" 69url { 70 src: 71 "https://github.com/hannesm/gmap/releases/download/0.1.0/gmap-0.1.0.tbz" 72 checksum: [ 73 "sha256=971dd65451472fbde6a621ac530f6eb7d6a3f28f983551a63eddd72e163c93ea" 74 "md5=aeea8ba33dc24e13d34d49ba2bd6e55a" 75 ] 76}