Implement type inference for expressions with the following (abstract) syntax:
Expr ::= num | var | Expr '+' Expr | if Expr then Expr else Expr | fun var -> Expr | Expr Expri.e., integers, variables, addition, multiplication, conditional, lambda abstraction and application. The type of a free variable should be a type variable. Report invalid typing using exceptions.