dictionary.ml 516 Bytes
Newer Older
POTTIER Francois's avatar
POTTIER Francois committed
1 2 3
(* Examples of mixing the monomorphic and polymorphic modes. *)

(* with a monomorphic 'env : *)
POTTIER Francois's avatar
POTTIER Francois committed
4 5 6 7 8
type ('a, 'b) dictionary =
  | Empty
  | NonEmpty of 'a * 'b * ('a, 'b) dictionary
[@@deriving visitors { variety = "map"; polymorphic = ["'b"] }]

POTTIER Francois's avatar
POTTIER Francois committed
9 10
(* with a polymorphic 'env : *)
(* dubious though, since the method [visit_'a] cannot use [env] *)
POTTIER Francois's avatar
POTTIER Francois committed
11 12 13 14
type ('a, 'b) dictionary2 =
  | Empty
  | NonEmpty of 'a * 'b * ('a, 'b) dictionary2
[@@deriving visitors { name = "map2"; variety = "map"; polymorphic = ["'b"; "'env"] }]