aboutsummaryrefslogtreecommitdiff
path: root/src/catalog.mli
diff options
context:
space:
mode:
Diffstat (limited to 'src/catalog.mli')
-rw-r--r--src/catalog.mli66
1 files changed, 47 insertions, 19 deletions
diff --git a/src/catalog.mli b/src/catalog.mli
index e871378..f39e87b 100644
--- a/src/catalog.mli
+++ b/src/catalog.mli
@@ -1,38 +1,66 @@
module type DATA_SIG = sig
- type 'a typ
+ type 'a t
type 'a returnType
- val compare_typ: 'a typ -> 'b typ -> ('a, 'b) Tools.cmp
+ val compare_typ: 'a t -> 'b t -> ('a, 'b) Tools.cmp
- val repr: Format.formatter -> 'a typ -> unit
+ val repr: Format.formatter -> 'a t -> unit
end
-module Make(D:DATA_SIG): sig
+module type CATALOG = sig
+
+ type 'a argument
+ type 'a returnType
type t
- type 'a t_function =
- | Fn1: 'b D.returnType * ('a -> 'b) -> 'a t_function
- | Fn2: 'c D.returnType * ('a -> 'b -> 'c) -> ('a * 'b) t_function
- | Fn3: 'd D.returnType * ('a -> 'b -> 'c -> 'd) -> ('a * 'b * 'c) t_function
+ (** Create a new catalog builder used for registering all the functions *)
+ type catalog_builder
+
+ (** Empty catalog *)
+ val empty: catalog_builder
- type 'a sig_typ =
- | T1: 'a D.typ -> 'a t_function sig_typ
- | T2: 'a D.typ * 'b D.typ -> ('a * 'b) t_function sig_typ
- | T3: 'a D.typ * 'b D.typ * 'c D.typ -> ('a * 'b * 'c) t_function sig_typ
+ val register1:
+ string -> (* The function name *)
+ 'a argument -> (* The signature *)
+ 'b returnType -> (* The return type *)
+ ('a -> 'b) -> (* The function to call *)
+ catalog_builder -> catalog_builder
+
+ val register2:
+ string -> (* The function name *)
+ ('a argument * 'b argument) ->(* The signature *)
+ 'c returnType -> (* The return type *)
+ ( 'a -> 'b -> 'c) -> (* The function to call*)
+ catalog_builder -> catalog_builder
+
+ val register3:
+ string -> (* The function name *)
+ ('a argument * 'b argument * 'c argument) -> (* The signature *)
+ 'd returnType -> (* The return type *)
+ ( 'a -> 'b -> 'c -> 'd) -> (* The function to call*)
+ catalog_builder -> catalog_builder
- (** Empty catalog *)
- val empty: t
- (** Register a new function in the catalog *)
- val register : t -> string -> 'a t_function sig_typ -> 'a t_function -> t
+ (** Compile the catalog *)
+ val compile: catalog_builder -> t
- (** Find a function with the given name and signature *)
- val find_function: t -> string -> 'a t_function sig_typ -> 'a t_function
- val repr: Format.formatter -> t -> unit
+ type result =
+ | R : 'a returnType * 'a -> result
+
+ val eval1: t -> string -> ('a argument * 'a) -> result
+
+ val eval2: t -> string -> ('a argument * 'a) -> ('b argument * 'b) -> result
+
+ val eval3: t -> string -> ('a argument * 'a) -> ('b argument * 'b) -> ('c argument * 'c) -> result
end
+
+module Make(D:DATA_SIG) : CATALOG
+ with type 'a argument = 'a D.t
+ and type 'a returnType = 'a D.returnType
+