2022-07-28 11:36:36 +03:00
|
|
|
(* This file is part of the Catala compiler, a specification language for tax
|
|
|
|
and social benefits computation rules. Copyright (C) 2020-2022 Inria,
|
|
|
|
contributor: Louis Gesbert <louis.gesbert@inria.fr>
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
|
|
|
use this file except in compliance with the License. You may obtain a copy of
|
|
|
|
the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
License for the specific language governing permissions and limitations under
|
|
|
|
the License. *)
|
|
|
|
|
2022-08-22 19:53:30 +03:00
|
|
|
open Definitions
|
2022-07-28 11:36:36 +03:00
|
|
|
|
|
|
|
(** {1 Variables and their collections} *)
|
|
|
|
|
2022-08-25 20:46:13 +03:00
|
|
|
(** This module provides types and helpers for Bindlib variables on the [gexpr]
|
2022-08-12 18:59:49 +03:00
|
|
|
type *)
|
2022-07-28 11:36:36 +03:00
|
|
|
|
2023-03-30 19:57:51 +03:00
|
|
|
type 'e t = ('a, 't) naked_gexpr Bindlib.var constraint 'e = ('a, 't) gexpr
|
|
|
|
type 'e vars = ('a, 't) naked_gexpr Bindlib.mvar constraint 'e = ('a, 't) gexpr
|
2022-07-28 11:36:36 +03:00
|
|
|
|
|
|
|
val make : string -> 'e t
|
|
|
|
val compare : 'e t -> 'e t -> int
|
2023-04-15 18:07:24 +03:00
|
|
|
val equal : 'e t -> 'e t -> bool
|
|
|
|
val hash : 'e t -> int
|
2022-07-28 11:36:36 +03:00
|
|
|
|
|
|
|
val translate : 'e1 t -> 'e2 t
|
|
|
|
(** Needed when converting from one AST type to another. See the note of caution
|
|
|
|
on [Bindlib.copy_var]. *)
|
|
|
|
|
2022-08-16 17:54:42 +03:00
|
|
|
type 'e var = 'e t
|
|
|
|
(** Alias to allow referring to the type in the submodules *)
|
|
|
|
|
2022-07-28 11:36:36 +03:00
|
|
|
(** Wrapper over [Set.S] but with a type variable for the AST type parameters.
|
|
|
|
Extend as needed *)
|
|
|
|
module Set : sig
|
2022-08-16 17:54:42 +03:00
|
|
|
type 'e t
|
2022-07-28 11:36:36 +03:00
|
|
|
|
|
|
|
val empty : 'e t
|
|
|
|
val singleton : 'e var -> 'e t
|
|
|
|
val add : 'e var -> 'e t -> 'e t
|
|
|
|
val remove : 'e var -> 'e t -> 'e t
|
|
|
|
val union : 'e t -> 'e t -> 'e t
|
|
|
|
val mem : 'e var -> 'e t -> bool
|
|
|
|
val of_list : 'e var list -> 'e t
|
|
|
|
val elements : 'e t -> 'e var list
|
2022-08-16 17:54:42 +03:00
|
|
|
val diff : 'e t -> 'e t -> 'e t
|
2023-04-15 18:07:24 +03:00
|
|
|
val iter : ('e var -> unit) -> 'e t -> unit
|
2022-07-28 11:36:36 +03:00
|
|
|
end
|
|
|
|
|
|
|
|
(** Wrapper over [Map.S] but with a type variable for the AST type parameters.
|
|
|
|
Extend as needed *)
|
|
|
|
module Map : sig
|
2022-08-16 17:54:42 +03:00
|
|
|
type ('e, 'x) t
|
2023-08-15 17:57:52 +03:00
|
|
|
type k0
|
2023-08-16 01:04:45 +03:00
|
|
|
|
2023-08-15 17:57:52 +03:00
|
|
|
exception Not_found of k0
|
|
|
|
|
2022-07-28 11:36:36 +03:00
|
|
|
val empty : ('e, 'x) t
|
|
|
|
val singleton : 'e var -> 'x -> ('e, 'x) t
|
|
|
|
val add : 'e var -> 'x -> ('e, 'x) t -> ('e, 'x) t
|
2024-05-30 17:10:21 +03:00
|
|
|
val remove : 'e var -> ('e, 'x) t -> ('e, 'x) t
|
2022-07-28 11:36:36 +03:00
|
|
|
val update : 'e var -> ('x option -> 'x option) -> ('e, 'x) t -> ('e, 'x) t
|
|
|
|
val find : 'e var -> ('e, 'x) t -> 'x
|
|
|
|
val find_opt : 'e var -> ('e, 'x) t -> 'x option
|
|
|
|
val bindings : ('e, 'x) t -> ('e var * 'x) list
|
|
|
|
val mem : 'e var -> ('e, 'x) t -> bool
|
|
|
|
|
|
|
|
val union :
|
|
|
|
('e var -> 'x -> 'x -> 'x option) -> ('e, 'x) t -> ('e, 'x) t -> ('e, 'x) t
|
|
|
|
|
|
|
|
val fold : ('e var -> 'x -> 'acc -> 'acc) -> ('e, 'x) t -> 'acc -> 'acc
|
2023-07-12 12:48:46 +03:00
|
|
|
val keys : ('e, 'x) t -> 'e var list
|
|
|
|
val values : ('e, 'x) t -> 'x list
|
2023-08-31 17:54:45 +03:00
|
|
|
|
|
|
|
val format_keys :
|
|
|
|
?pp_sep:(Format.formatter -> unit -> unit) ->
|
|
|
|
Format.formatter ->
|
|
|
|
('e, 'x) t ->
|
|
|
|
unit
|
2022-07-28 11:36:36 +03:00
|
|
|
end
|