File: dictionary.ml

package info (click to toggle)
ocaml-visitors 20200210-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,896 kB
  • sloc: ml: 4,077; makefile: 44; sh: 18
file content (14 lines) | stat: -rw-r--r-- 516 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
(* Examples of mixing the monomorphic and polymorphic modes. *)

(* with a monomorphic 'env : *)
type ('a, 'b) dictionary =
  | Empty
  | NonEmpty of 'a * 'b * ('a, 'b) dictionary
[@@deriving visitors { variety = "map"; polymorphic = ["'b"] }]

(* with a polymorphic 'env : *)
(* dubious though, since the method [visit_'a] cannot use [env] *)
type ('a, 'b) dictionary2 =
  | Empty
  | NonEmpty of 'a * 'b * ('a, 'b) dictionary2
[@@deriving visitors { name = "map2"; variety = "map"; polymorphic = ["'b"; "'env"] }]