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 22[GADT](https://en.wikipedia.org/wiki/Generalized_algebraic_data_type) 'a key) 23and outputs a type-safe Map where each 'a key is associated with a 'a value. 24This removes the need for additional packing. It uses OCaml's stdlib 25[Map](http://caml.inria.fr/pub/docs/manual-ocaml/libref/Map.html) data 26structure. 27 28```OCaml 29type _ k = 30 | A : int k 31 | B : string k 32 33module K = struct 34 type 'a t = 'a k 35 36 let compare : type a b. a t -> b t -> (a, b) Gmap.Order.t = fun t t' -> 37 let open Gmap.Order in 38 match t, t' with 39 | A, A -> Eq | A, _ -> Lt | _, A -> Gt 40 | B, B -> Eq 41 42 let pp : type a. Format.formatter -> a t -> a -> unit = fun ppf t v -> 43 match t, v with 44 | A, x -> Fmt.pf ppf "A %d" x 45 | B, s -> Fmt.pf ppf "B %s" s 46end 47 48module M = Gmap.Make(K) 49 50 51let () = 52 let m = M.empty in 53 ... 54 match M.find A m with 55 | Some x -> Printf.printf "got %d\\n" x 56 | None -> Printf.printf "found nothing\\n" 57``` 58 59This is already an exhaustive pattern match: there is no need for another case 60(for the constructor `B`) since the type system knows that looking for `A` will 61result in an `int`. 62 63Motivation came from parsing of protocols which usually specify optional values 64and extensions via a tag-length-value (TLV) mechanism: for a given tag the 65structure of value is different - see for example IP options, TCP options, DNS 66resource records, TLS hello extensions, etc. 67 68Discussing this problem with Justus Matthiesen during summer 2017, we came up 69with this design. Its main difference to Daniel C. Bünzli's 70[hmap](http://erratique.ch/software/hmap) is that in gmap the key-value GADT 71type must be provided when instantiating the functor. In hmap, keys are created 72dynamically.""" 73url { 74 src: 75 "https://github.com/hannesm/gmap/releases/download/0.2.0/gmap-0.2.0.tbz" 76 checksum: [ 77 "sha256=00c6a2186c0c9908f6057566ac72de062b26ac5b1f5d0d78721c8526a580884d" 78 "md5=fbf9d1d5a38c2c86ef2f122e22359896" 79 ] 80}