Lets parse the definition of eval.
text | syntactic category | |
let rec eval : type a. a term -> a = ⋯ (eval x) | is a | definition |
eval : type a. a term -> a = ⋯ (eval x) | is this extension of a | let-binding |
Yet I am surprised that they consider this construct sugar. I shall have to understand what they translate this into!
let rec f : type t1 t2. t1 * t2 list -> t1 = function (a, b) -> a;; f (4, []);; ==> 4
let f : type t1 t2. t1 * t2 -> t1 = function (a, b) -> a;;Desugaring:
let f : 't1 't2. 't1 * 't2 -> 't1 = fun (type t1) (type t2) -> (function (a, b) -> a : t1 * t2 -> t1);;OCaml likes the above. Parsing that:
text | syntactic category | |
let f : 't1 't2. 't1 * 't2 -> 't1 = ⋯ | is a | definition |
f : 't1 't2. 't1 * 't2 -> 't1 = ⋯ | is this extension of a | let-binding |
't1 't2. 't1 * 't2 -> 't1 | is a | poly-typexpr |
fun (type t1) (type t2) -> (function (a, b) -> a : t1 * t2 -> t1) | is an | expr |
(type t1) (type t2) -> (function (a, b) -> a : t1 * t2 -> t1) | is a | multiple-matching |
(type t1) | is this extension of a | parameter |