Ocaml AST implementation with mutually recursive functions

It’s not easy without seeing the code, but I imagine that somewhere it is pattern-matching as if it were using the old definition of expr, e.g.

| Plus (f, g) -> (* [Plus] is a constructor with two arguments, [f] 
                    and [g] *)

when what you’ll now need is something like e.g.

| Plus { arg1; arg2 } -> (* [Plus] is a constructor with one argument,
                            which is an [args] record with two fields named
                            [arg1] and [arg2] *)

The compiler error is probably coming from the fact that the former is a pattern for a tuple (f, g) of type ('a * 'b), but the type-system knows that Plus can only ever contain a single value of type args.

1 Like