Commit f97e1ea4 authored by POTTIER Francois's avatar POTTIER Francois

Split expr15.

parent 131d7d1f
type expr =
| EConst of int
| EAdd of expr * expr
[@@deriving visitors { name = "size"; variety = "reduce"; ancestors = ["VisitorsRuntime.addition_monoid"] }]
let size : expr -> int =
let o = object
inherit [_] size as super
method! visit_EConst () (_ : int) = 0
method! visit_expr () e =
1 + super # visit_expr () e
end in
o # visit_expr ()
let () =
Printf.printf "%d\n" (size (EAdd (EConst 22, EConst 11)))
[@@deriving visitors { variety = "reduce" }]
open Expr15
let size : expr -> int =
let o = object
inherit [_] reduce as super
inherit [_] VisitorsRuntime.addition_monoid
method! visit_EConst _ _ = 0
method! visit_expr env e =
1 + super # visit_expr env e
end in
o # visit_expr ()
open Expr15
open Expr15b
let () =
Printf.printf "%d\n" (size (EAdd (EConst 22, EConst 11)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment