aboutsummaryrefslogtreecommitdiff
path: root/src/catalog.mli
blob: f39e87b9275a8e6b6e07b5afe7105b8e48265b28 (plain)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
module type DATA_SIG = sig

  type 'a t
  
  type 'a returnType
  
  val compare_typ: 'a t -> 'b t -> ('a, 'b) Tools.cmp

  val repr: Format.formatter -> 'a t -> unit
  
end

module type CATALOG = sig

  type 'a argument
  type 'a returnType

  type t

  (** Create a new catalog builder used for registering all the functions *)
  type catalog_builder
  
  (** Empty catalog *)
  val empty: catalog_builder

  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


  (** Compile the catalog *)
  val compile: catalog_builder -> t


  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