type ins = | Basic of char (* a *) | Terminate (* ! *) | Ptest of char (* +a *) | Ntest of char (* -a *) | Jump of int (* #1 *) | Concat of ins list (* a;b *) | Repeat of ins * int (* a2 : execute a twice *) | Loop of ins (* a* : repeat a infinitely *) | Program of char (* X *) | Empty type program = ins list (* Natural numbers *) type natural = Infinity | N of int let natural_binop binop a b = match (a, b) with | N i, N j -> N (binop i j) | _ -> Infinity let ( ++ ) = natural_binop ( + ) let ( -- ) = natural_binop ( - ) let ( ** ) = natural_binop ( * ) let ( // ) = natural_binop ( / ) exception Fatal_error of string exception Ins_error of ins * string exception Program_error of program * string