| |
let print_type t =
let rec print k out t =
let string x = Printf.fprintf out x in
let paren p f =
if k > p then string "("; f(); if k > p then string ")" in
let t = repr t in
begin match desc t with
| Tvar n -> string "'a%d" n
| Tcon (Tint, []) -> string "int"
| Tcon (Tarrow, [t1; t2]) ->
paren 0 (fun() ->
string "%a -> %a" (print 1) t1 (print 0) t2)
| Tcon (g, l) -> raise (Arity (t, t))
end in
acyclic t;
print 0 stdout t;; |
|