%{ open Expr open Types %} %token PLUS TIMES %token TOP BOTTOM EXFALSO %token LPAREN RPAREN %token FUN ARR COLON %token VARID %token TYID %token EOL %right ARR %start main %type main %% main: e=expression EOL { e } ty_annot: | id=VARID COLON t=ty { (id, t) } ty: | id=TYID { TVar(id) } | LPAREN t=ty RPAREN { t } | t1=ty ARR t2=ty { Arr(t1, t2) } expression: | FUN LPAREN annot=ty_annot RPAREN ARR e=expression { Fun (annot, e) } | e=app_expr { e } app_expr: | e=app_expr a=atomic { App (e, a) } | a=atomic { a } atomic: | id=VARID { Var id } | LPAREN e=expression RPAREN { e }