summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Seguin <guillaume@segu.in>2009-01-23 04:21:51 +0100
committerGuillaume Seguin <guillaume@segu.in>2009-01-23 04:21:51 +0100
commitc29508979f6371d506ca539e34216e5ec6d414b4 (patch)
treed8741fda06117631c57b84aa91f338cd3aafa688
parentfceca1a2201eae51a5897b69ace85b0c5b773ac2 (diff)
downloadpetitcaml-c29508979f6371d506ca539e34216e5ec6d414b4.tar.gz
petitcaml-c29508979f6371d506ca539e34216e5ec6d414b4.tar.bz2
[petitcaml] Fix indent
-rw-r--r--typing.ml78
1 files changed, 40 insertions, 38 deletions
diff --git a/typing.ml b/typing.ml
index a929d9c..1fe398e 100644
--- a/typing.ml
+++ b/typing.ml
@@ -36,46 +36,48 @@ let canon_string t tvar_names =
let next_tvar_char = ref 97
and tvar_names = ref tvar_names
in
- let rec aux t =
- match t with
- | Tint -> "int"
- | Tstring -> "string"
- | Tunit -> "unit"
- | Tbool -> "bool"
- | Tarrow (t1, t2) -> aux_arrow t1 t2
- | Tproduct (t::l) ->
- Printf.sprintf "%s"
- (List.fold_left (fun base t ->
- Printf.sprintf "%s * %s"
- base (aux t))
- (aux t)
- l)
- | Tproduct _ -> failwith "canon_string : Unreachable matching"
- | Tlist t ->
- Printf.sprintf "%s list" (aux t)
- | Tvar tvar ->
- try
- Imap.find tvar.id !tvar_names
- with Not_found ->
- let tvar_name =
- (Printf.sprintf "'%c" (char_of_int !next_tvar_char))
- in
- incr next_tvar_char;
- tvar_names := Imap.add tvar.id tvar_name !tvar_names;
- tvar_name
- and aux_arrow t1 t2 =
- let s1 =
- match t1 with
- | Tarrow _ -> Printf.sprintf "(%s)" (aux t1)
- | _ -> (aux t1)
- in
- let s2 = aux t2
+ let rec aux t =
+ match t with
+ | Tint -> "int"
+ | Tstring -> "string"
+ | Tunit -> "unit"
+ | Tbool -> "bool"
+ | Tarrow (t1, t2) -> aux_arrow t1 t2
+ | Tproduct (t::l) ->
+ Printf.sprintf "%s"
+ (List.fold_left (fun base t ->
+ Printf.sprintf "%s * %s"
+ base (aux t))
+ (aux t)
+ l)
+ | Tproduct _ -> failwith "canon_string : Unreachable matching"
+ | Tlist t ->
+ Printf.sprintf "%s list" (aux t)
+ | Tvar tvar ->
+ try
+ Imap.find tvar.id !tvar_names
+ with Not_found ->
+ let tvar_name =
+ (Printf.sprintf "'%c" (char_of_int !next_tvar_char))
+ in
+ incr next_tvar_char;
+ tvar_names := Imap.add tvar.id
+ tvar_name
+ !tvar_names;
+ tvar_name
+ and aux_arrow t1 t2 =
+ let s1 =
+ match t1 with
+ | Tarrow _ -> Printf.sprintf "(%s)" (aux t1)
+ | _ -> (aux t1)
in
- Printf.sprintf "%s -> %s" s1 s2
- in
- let s = aux (canon t)
+ let s2 = aux t2
+ in
+ Printf.sprintf "%s -> %s" s1 s2
in
- s, !tvar_names
+ let s = aux (canon t)
+ in
+ s, !tvar_names
(* Pour le debug *)
let print_canon_string t =