All Projects → hannesm → gmap

hannesm / gmap

Licence: other
heterogenous Map over a GADT

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to gmap

array-keyed-map
JS datastructure, like Map, but the keys are arrays
Stars: ✭ 29 (-27.5%)
Mutual labels:  map, data-structure
Gods
GoDS (Go Data Structures). Containers (Sets, Lists, Stacks, Maps, Trees), Sets (HashSet, TreeSet, LinkedHashSet), Lists (ArrayList, SinglyLinkedList, DoublyLinkedList), Stacks (LinkedListStack, ArrayStack), Maps (HashMap, TreeMap, HashBidiMap, TreeBidiMap, LinkedHashMap), Trees (RedBlackTree, AVLTree, BTree, BinaryHeap), Comparators, Iterators, …
Stars: ✭ 10,883 (+27107.5%)
Mutual labels:  map, data-structure
stream
Go Stream, like Java 8 Stream.
Stars: ✭ 60 (+50%)
Mutual labels:  map
UMapControl
轻量级跨平台瓦片地图库
Stars: ✭ 35 (-12.5%)
Mutual labels:  map
map-with-me
🌍 Create collaborative maps with your friends (and enemies)
Stars: ✭ 23 (-42.5%)
Mutual labels:  map
localizator
Localizator is a flutter application that provides your current/given position,and gives you weather Forecasts
Stars: ✭ 46 (+15%)
Mutual labels:  map
mapus
A map tool with real-time collaboration 🗺️
Stars: ✭ 2,687 (+6617.5%)
Mutual labels:  map
OpenHGNN
This is an open-source toolkit for Heterogeneous Graph Neural Network(OpenHGNN) based on DGL.
Stars: ✭ 264 (+560%)
Mutual labels:  heterogeneous
hackerrank-30-Days-of-Code
Hackerrank Solutions of "30 Days of Code Challenges "
Stars: ✭ 23 (-42.5%)
Mutual labels:  data-structure
openskimap.org
The front end for OpenSkiMap.org.
Stars: ✭ 23 (-42.5%)
Mutual labels:  map
MapMoves
View your Moves app and Arc app/LocoKit location history summary on map
Stars: ✭ 35 (-12.5%)
Mutual labels:  map
fBomb
Mapping where in the world people drop the fBomb
Stars: ✭ 52 (+30%)
Mutual labels:  map
UltraMapper
A fast and lightweight object-to-object .NET mapper.
Stars: ✭ 28 (-30%)
Mutual labels:  map
mviewer
Visualiseur géographique thématique basé sur OpenLayers 6.3.1 et Bootstrap 3.3.6 / cartographic application based on OpenLayers and Bootstrap
Stars: ✭ 53 (+32.5%)
Mutual labels:  map
OS-Open-Zoomstack-Stylesheets
Cartographic Stylesheets for OS Open Zoomstack
Stars: ✭ 36 (-10%)
Mutual labels:  map
mars2d
【Mars2D平台 】主仓库,包含所有开源仓库清单导航
Stars: ✭ 182 (+355%)
Mutual labels:  map
telegram-nearby-map
Discover the location of nearby Telegram users 📡🌍
Stars: ✭ 329 (+722.5%)
Mutual labels:  map
the-entitytainer
A single header library for managing game entity hierarchies.
Stars: ✭ 31 (-22.5%)
Mutual labels:  data-structure
vtm
OpenGL vector map library - running on Android, iOS, Desktop and browser.
Stars: ✭ 212 (+430%)
Mutual labels:  map
ustd
Micro-standard-library providing minimal and portable array, queue and map for attiny avr, arduinos, esp8266/32 and linux, mac
Stars: ✭ 14 (-65%)
Mutual labels:  map

Gmap - heterogenous maps over a GADT

%%VERSION%%

Gmap exposes the functor Make which takes a key type (a GADT 'a key) and outputs a type-safe Map where each 'a key is associated with a 'a value. This removes the need for additional packing. It uses OCaml's stdlib Map data structure.

type _ key =
  | I : int key
  | S : string key

module K = struct
  type 'a t = 'a key

  let compare : type a b. a t -> b t -> (a, b) Gmap.Order.t = fun t t' ->
    let open Gmap.Order in
    match t, t' with
    | I, I -> Eq | I, _ -> Lt | _, I -> Gt
    | S, S -> Eq
end

module M = Gmap.Make(K)


let () =
  let m = M.empty in
  ...
  match M.find I m with
  | Some x -> Printf.printf "got %d\n" x
  | None -> Printf.printf "found nothing\n"

This is already an exhaustive pattern match: there is no need for another case (for the constructor S) since the type system knows that looking for I will result in an int.

Motivation came from parsing of protocols which usually specify optional values and extensions via a tag-length-value (TLV) mechanism: for a given tag the structure of value is different - see for example IP options, TCP options, DNS resource records, TLS hello extensions, etc.

Discussing this problem with Justus Matthiesen during summer 2017, we came up with this design. Its main difference to Daniel C. Bünzli's hmap is that in gmap the key-value GADT type must be provided when instantiating the functor. In hmap, keys are created dynamically.

Documentation

Build Status

API documentation is available online.

Installation

You need opam installed on your system. The command

opam install gmap

will install this library.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].