Pie*_* G. 3 ocaml gadt locally-abstract-type
在ocaml手册第 7.20节的GADT基本示例中,'type a'的含义是什么??为什么宣称"eval:一个术语 - > a"是不够的?
type _ term =
| Int : int -> int term
| Add : (int -> int -> int) term
| App : ('b -> 'a) term * 'b term -> 'a term
let rec eval : type a. a term -> a = function
| Int n -> n (* a = int *)
| Add -> (fun x y -> x+y) (* a = int -> int -> int *)
| App(f,x) -> (eval f) (eval x)
Run Code Online (Sandbox Code Playgroud)