type term = Div of (term * term) | Con of int;;
type 'a m = state -> 'a * state and state = int;;
let answer = (Div (Div (Con 1972, Con 2), Con 23))
and err = (Div (Con 1, Con 0))
and ( * ) m k = fun x -> let a, y = m x in k a y
and unit a = fun x -> (a, x)
and tick = fun x -> ((), x + 1)
in let rec eval t = match t with (Con a) -> unit a
| Div (t, u) ->
(eval t) * fun a ->
(eval u) * fun b ->
tick * fun _ ->
(unit (a/b)) in
let c, a = (eval answer 0) in Printf.printf "%d, %d\n" c a
(* => 42, 2 *)