ali

OCaml label syntax

In Uncategorized on October 28, 2009 at 8:36 pm
let f x:int = "hi";;
(* Error: This expression has type string but an expression was
   expected of type int *)

let f (x:int) = "hi";;
(* val f : int -> string = <fun> *)

let f ~x:int = "hi";;
(* val f : x:'a -> string = <fun> *)

let f ~x:(y:int) = "hi";;
(* val f : x:int -> string = <fun> *)

let f ~(x:int) = "hi";;
(* val f : x:int -> string = <fun> *)
Advertisements
%d bloggers like this: