Raw text file


let a = `A and b = `B (1, true) and b' = `B "foo"


let l1 = [ `A ; `B 1 ; `C false ];;

let l2 = `A ::  `D :: l1;;

(* Type error when we try to add a constructor with an incompatible type *)
(* let _ = `B 'b' :: l1 *)

(* We decide that the type of l1 should not be instantiable anymore *)
let l3 = (l1 :  [ `A | `B of int | `C of bool ] list)

(* Type error when we try to add a new constructor to l3 *)
(* let _ = `E :: l3;; *)


let f = function
  | `A -> `B
  | `C | `D -> `D;;

(* Type weakening by instantiation *)
let f' = (f : ([ `A | `C ] -> [`B | `D | `E ]))

(* Type weakening by explicit coercion *)
let f'' = (f' :> ([`A ] -> [ `B | `D | `E | `F]))

This document was generated using caml2html