1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
(* SPDX-License-Identifier: AGPL-3.0-or-later *)
(* Copyright © 2021-2024 OCamlPro *)
(* Written by the Owi programmers *)

open Types

type t = int

module IMap = Map.Make (Int)

type 'a collection =
  { c : ('a * binary func_type) IMap.t
  ; last : int
  }

let empty = { c = IMap.empty; last = 0 }

let add f t { last; c } =
  let c = IMap.add last (f, t) c in
  (last, { c; last = succ last })

let get i c =
  let v, _ = IMap.find i c.c in
  v

let get_typ i c =
  let _, t = IMap.find i c.c in
  t