From 023c11470e32744a43b7e3c7c248f3c47ebdc687 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 21 Nov 2016 17:06:19 +0100 Subject: Use gadt for function catalog --- evaluator.mli | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100755 evaluator.mli (limited to 'evaluator.mli') diff --git a/evaluator.mli b/evaluator.mli new file mode 100755 index 0000000..9fa280b --- /dev/null +++ b/evaluator.mli @@ -0,0 +1,65 @@ +val repr: (ScTypes.refs -> ScTypes.types ScTypes.Refs.range) -> ScTypes.expression -> ScTypes.types + +(** Type definitions *) + +type 'a typ +val t_bool: DataType.Bool.t typ +val t_int: DataType.Num.t typ +val t_string: UTF8.t typ +val t_list: 'a typ -> 'a list typ + +(** Result formats *) + +type 'a result + +(** Numeric (any format) *) +val f_num: DataType.Num.t result + +(** Date *) +val f_date: DataType.Num.t result + +(** Number *) +val f_number: DataType.Num.t result + +(** Boolean result *) +val f_bool: DataType.Bool.t result + +(** String *) +val f_string: DataType.String.t result + +(** Catalog *) + +(** We cannot update an existing function. Any [registerX] function will raise + [RegisteredFunction] if a function with the same signature already exists in the catalog. *) +exception RegisteredFunction + +val register0: + string -> (* The function name *) + 'a result -> (* The return type *) + (unit -> 'a) (* The function to call *) + -> unit + +val register1: + string -> (* The function name *) + 'a typ -> (* The signature *) + 'b result -> (* The return type *) + ('a -> 'b) (* The function to call *) + -> unit + +val register2: + string -> (* The function name *) + ('a typ * 'b typ) ->(* The signature *) + 'c result -> (* The return type *) + ( 'a -> 'b -> 'c) (* The function to call*) + -> unit + +val register3: + string -> (* The function name *) + ('a typ * 'b typ * 'c typ) ->(* The signature *) + 'd result -> (* The return type *) + ( 'a -> 'b -> 'c -> 'd) (* The function to call*) + -> unit + + +(** [wrap f] run [f] inside a context where there is no functions *) +val wrap: (unit -> 'a) -> 'a -- cgit v1.2.3