summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2009-01-23 04:25:52 +0100
committerGuillaume Seguin <guillaume@segu.in>2009-01-23 04:25:52 +0100
commit8cff7cfa6d9c2bbf83483e5824fd686d7f5b9ca5 (patch)
tree176cc9aae39c73c97dd93ca2529a8fe1a5c6093f
parent02aa727ea3c8b58b5cc58ea77d21a9188e6b4d19 (diff)
downloadpetitcaml-8cff7cfa6d9c2bbf83483e5824fd686d7f5b9ca5.tar.gz
petitcaml-8cff7cfa6d9c2bbf83483e5824fd686d7f5b9ca5.tar.bz2
[petitcaml] Improve list types printing
-rw-r--r--tests/typing/match.ml2
-rw-r--r--typing.ml7
2 files changed, 7 insertions, 2 deletions
diff --git a/tests/typing/match.ml b/tests/typing/match.ml
index a279e78..d79b77f 100644
--- a/tests/typing/match.ml
+++ b/tests/typing/match.ml
@@ -1,7 +1,7 @@
(*
return : 0
output :
-h : int * 'a list -> int
+h : (int * 'a) list -> int
*)
let rec h l =
match l with
diff --git a/typing.ml b/typing.ml
index 1fe398e..6ee453b 100644
--- a/typing.ml
+++ b/typing.ml
@@ -52,7 +52,7 @@ let canon_string t tvar_names =
l)
| Tproduct _ -> failwith "canon_string : Unreachable matching"
| Tlist t ->
- Printf.sprintf "%s list" (aux t)
+ Printf.sprintf "%s list" (aux_list t)
| Tvar tvar ->
try
Imap.find tvar.id !tvar_names
@@ -74,6 +74,11 @@ let canon_string t tvar_names =
let s2 = aux t2
in
Printf.sprintf "%s -> %s" s1 s2
+ and aux_list t =
+ match t with
+ | Tarrow (_, _)
+ | Tproduct _ -> Printf.sprintf "(%s)" (aux t)
+ | _ -> aux t
in
let s = aux (canon t)
in