File: test02.ml

package info (click to toggle)
ocaml-visitors 20180513-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,640 kB
  • sloc: ml: 4,063; makefile: 120; sh: 13
file content (31 lines) | stat: -rw-r--r-- 888 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
type term =
  | TUnit
  | TIntLiteral of int
  | TVar of string
  | TLambda of string * term
  | TApp of term * term
  | TPair of { fst: term; snd: term }
  | TTuple of term_list

and term_list =
  | TLNil
  | TLCons of (term * term_list)

[@@deriving
     visitors { variety = "iter"; concrete = true },
     visitors { variety = "map"; concrete = true },
     visitors { variety = "reduce"; concrete = true; ancestors = ["VisitorsRuntime.addition_monoid"] },
     visitors { variety = "endo"; concrete = true },
     visitors { variety = "iter2"; concrete = true },
     visitors { variety = "map2"; concrete = true },
     visitors { variety = "reduce2"; concrete = true; ancestors = ["VisitorsRuntime.addition_monoid"] }
]

let identity : term =
  TLambda ("x", TVar "x")

let () =
  new iter#visit_term 33 identity

let () =
  new iter#visit_term 33 (new map#visit_term () identity)