File: expr08extra.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 (15 lines) | stat: -rw-r--r-- 447 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
open Expr12
open Expr08
open Expr08double

let econst e = h (EConst e)
let eadd e1 e2 = h (EAdd (e1, e2))

let e1 : hexpr = eadd (econst 0) (econst 1)
let e2 : hexpr = new hmap # visit_'expr () e1 (* identity *)
let () =
  Printf.printf "%b\n%!" (e1 == e2) (* should print true *)
let e3 : hexpr = eadd (econst 0) (econst 2)
let e4 : hexpr = double e1 (* should produce [e3] *)
let () =
  Printf.printf "%b\n%!" (e3 == e4) (* should print true *)