Index: boot/ocamlc
===================================================================
RCS file: /net/pauillac/caml/repository/csl/boot/ocamlc,v
retrieving revision 1.314
diff -u -r1.314 ocamlc
Binary files /tmp/cvsOgc6Vj and ocamlc differ
Index: boot/ocamllex
===================================================================
RCS file: /net/pauillac/caml/repository/csl/boot/ocamllex,v
retrieving revision 1.246
diff -u -r1.246 ocamllex
Binary files /tmp/cvsdkTOqJ and ocamllex differ
Index: bytecomp/translmod.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/bytecomp/translmod.ml,v
retrieving revision 1.48
diff -u -r1.48 translmod.ml
--- bytecomp/translmod.ml	9 Apr 2004 13:32:27 -0000	1.48
+++ bytecomp/translmod.ml	17 May 2004 11:52:23 -0000
@@ -138,21 +138,21 @@
                     [Lvar undef_function_id])
           | _ -> raise Not_found in
         init_v :: init_value_struct env rem
-    | Tsig_type(id, tdecl) :: rem ->
+    | Tsig_type(id, tdecl, _) :: rem ->
         init_value_struct (Env.add_type id tdecl env) rem
     | Tsig_exception(id, edecl) :: rem ->
         transl_exception
           id (Some Predef.path_undefined_recursive_module) edecl ::
         init_value_struct env rem
-    | Tsig_module(id, mty) :: rem ->
+    | Tsig_module(id, mty, _) :: rem ->
         init_value_mod env mty ::
         init_value_struct (Env.add_module id mty env) rem
     | Tsig_modtype(id, minfo) :: rem ->
         init_value_struct (Env.add_modtype id minfo env) rem
-    | Tsig_class(id, cdecl) :: rem ->
+    | Tsig_class(id, cdecl, _) :: rem ->
         Translclass.dummy_class (Lvar undef_function_id) ::
         init_value_struct env rem
-    | Tsig_cltype(id, ctyp) :: rem ->
+    | Tsig_cltype(id, ctyp, _) :: rem ->
         init_value_struct env rem
   in
   try
Index: camlp4/top/rprint.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/camlp4/top/rprint.ml,v
retrieving revision 1.12
diff -u -r1.12 rprint.ml
--- camlp4/top/rprint.ml	23 Sep 2003 12:52:34 -0000	1.12
+++ camlp4/top/rprint.ml	17 May 2004 12:21:25 -0000
@@ -313,12 +313,14 @@
         print_out_signature items ]
 and print_out_sig_item ppf =
   fun
-  [ Osig_class vir_flag name params clt ->
-      fprintf ppf "@[<2>class%s@ %a%s@ :@ %a@]"
+  [ Osig_class vir_flag name params clt rs ->
+      fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]"
+        (if rs = Orec_next then "and" else "class")
         (if vir_flag then " virtual" else "") print_out_class_params params
         name Toploop.print_out_class_type.val clt
-  | Osig_class_type vir_flag name params clt ->
-      fprintf ppf "@[<2>class type%s@ %a%s@ =@ %a@]"
+  | Osig_class_type vir_flag name params clt rs ->
+      fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]"
+        (if rs = Orec_next then "and" else "class type")
         (if vir_flag then " virtual" else "") print_out_class_params params
         name Toploop.print_out_class_type.val clt
   | Osig_exception id tyl ->
@@ -328,10 +330,16 @@
   | Osig_modtype name mty ->
       fprintf ppf "@[<2>module type %s =@ %a@]" name
         Toploop.print_out_module_type.val mty
-  | Osig_module name mty ->
-      fprintf ppf "@[<2>module %s :@ %a@]" name
+  | Osig_module name mty rs ->
+      fprintf ppf "@[<2>%s %s :@ %a@]" name
+        (match rs with [ Orec_not -> "module"
+                       | Orec_first -> "module rec"
+                       | Orec_next -> "and" ])
         Toploop.print_out_module_type.val mty
-  | Osig_type tdl -> print_out_type_decl_list ppf tdl
+  | Osig_type td rs ->
+      print_out_type_decl
+          (if rs = Orec_next then "and" else "type")
+          ppf td
   | Osig_value name ty prims ->
       let kwd = if prims = [] then "value" else "external" in
       let pr_prims ppf =
@@ -345,16 +353,7 @@
       in
       fprintf ppf "@[<2>%s %a :@ %a%a@]" kwd value_ident name
         Toploop.print_out_type.val ty pr_prims prims ]
-and print_out_type_decl_list ppf =
-  fun
-  [ [] -> ()
-  | [x] -> print_out_type_decl "type" ppf x
-  | [x :: l] ->
-      do {
-        print_out_type_decl "type" ppf x;
-        List.iter (fun x -> fprintf ppf "@ %a" (print_out_type_decl "and") x)
-          l
-      } ]
+
 and print_out_type_decl kwd ppf (name, args, ty, constraints) =
   let constrain ppf (ty, ty') =
     fprintf ppf "@ @[<2>constraint %a =@ %a@]" Toploop.print_out_type.val ty
Index: ocamldoc/odoc_env.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/ocamldoc/odoc_env.ml,v
retrieving revision 1.6
diff -u -r1.6 odoc_env.ml
--- ocamldoc/odoc_env.ml	24 Nov 2003 10:39:31 -0000	1.6
+++ ocamldoc/odoc_env.ml	17 May 2004 12:23:31 -0000
@@ -52,9 +52,9 @@
   let f env item =
     match item with
       Types.Tsig_value (ident, _) -> { env with env_values = (rel_name ident, qualify ident) :: env.env_values }
-    | Types.Tsig_type (ident,_ ) -> { env with env_types = (rel_name ident, qualify ident) :: env.env_types }
+    | Types.Tsig_type (ident,_,_) -> { env with env_types = (rel_name ident, qualify ident) :: env.env_types }
     | Types.Tsig_exception (ident, _) -> { env with env_exceptions = (rel_name ident, qualify ident) :: env.env_exceptions }
-    | Types.Tsig_module (ident, modtype) -> 
+    | Types.Tsig_module (ident, modtype, _) -> 
         let env2 = 
           match modtype with (* A VOIR : le cas oł c'est un identificateur, dans ce cas on n'a pas de signature *)
             Types.Tmty_signature s -> add_signature env (qualify ident) ~rel: (rel_name ident) s
@@ -73,8 +73,8 @@
               |  _ -> env
         in
         { env2 with env_module_types = (rel_name ident, qualify ident) :: env2.env_module_types }
-    | Types.Tsig_class (ident, _) -> { env with env_classes = (rel_name ident, qualify ident) :: env.env_classes }
-    | Types.Tsig_cltype (ident, _) -> { env with env_class_types = (rel_name ident, qualify ident) :: env.env_class_types }
+    | Types.Tsig_class (ident, _, _) -> { env with env_classes = (rel_name ident, qualify ident) :: env.env_classes }
+    | Types.Tsig_cltype (ident, _, _) -> { env with env_class_types = (rel_name ident, qualify ident) :: env.env_class_types }
   in
   List.fold_left f env signat 
 
Index: ocamldoc/odoc_sig.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/ocamldoc/odoc_sig.ml,v
retrieving revision 1.29
diff -u -r1.29 odoc_sig.ml
--- ocamldoc/odoc_sig.ml	2 Apr 2004 15:10:57 -0000	1.29
+++ ocamldoc/odoc_sig.ml	17 May 2004 12:23:31 -0000
@@ -51,13 +51,13 @@
           Hashtbl.add table (V (Name.from_ident ident)) signat
       | Types.Tsig_exception (ident, _) ->
           Hashtbl.add table (E (Name.from_ident ident)) signat
-      | Types.Tsig_type (ident, _) ->
+      | Types.Tsig_type (ident, _, _) ->
           Hashtbl.add table (T (Name.from_ident ident)) signat
-      | Types.Tsig_class (ident,_) ->
+      | Types.Tsig_class (ident, _, _) ->
           Hashtbl.add table (C (Name.from_ident ident)) signat
-      | Types.Tsig_cltype (ident, _) ->
+      | Types.Tsig_cltype (ident, _, _) ->
           Hashtbl.add table (CT (Name.from_ident ident)) signat
-      | Types.Tsig_module (ident, _) ->
+      | Types.Tsig_module (ident, _, _) ->
           Hashtbl.add table (M (Name.from_ident ident)) signat
       | Types.Tsig_modtype (ident,_) ->
           Hashtbl.add table (MT (Name.from_ident ident)) signat
@@ -80,22 +80,22 @@
 
     let search_type table name =
       match Hashtbl.find table (T name) with
-      | (Types.Tsig_type (_, type_decl)) -> type_decl
+      | (Types.Tsig_type (_, type_decl, _)) -> type_decl
       | _ -> assert false
 
     let search_class table name =
       match Hashtbl.find table (C name) with
-      | (Types.Tsig_class (_, class_decl)) -> class_decl
+      | (Types.Tsig_class (_, class_decl, _)) -> class_decl
       | _ -> assert false
 
     let search_class_type table name =
       match Hashtbl.find table (CT name) with
-      | (Types.Tsig_cltype (_, cltype_decl)) -> cltype_decl
+      | (Types.Tsig_cltype (_, cltype_decl, _)) -> cltype_decl
       | _ -> assert false
 
     let search_module table name =
       match Hashtbl.find table (M name) with
-      | (Types.Tsig_module (ident, module_type)) -> module_type
+      | (Types.Tsig_module (ident, module_type, _)) -> module_type
       | _ -> assert false
 
     let search_module_type table name =
Index: otherlibs/labltk/browser/searchid.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/otherlibs/labltk/browser/searchid.ml,v
retrieving revision 1.21
diff -u -r1.21 searchid.ml
--- otherlibs/labltk/browser/searchid.ml	2 Jul 2003 09:14:30 -0000	1.21
+++ otherlibs/labltk/browser/searchid.ml	17 May 2004 12:06:39 -0000
@@ -220,7 +220,7 @@
   begin fun item -> match item with
         Tsig_value (id, vd) ->
           if matches vd.val_type then [lid_of_id id, Pvalue] else []
-      | Tsig_type (id, td) ->
+      | Tsig_type (id, td, _) ->
           if
           begin match td.type_manifest with
             None -> false
@@ -238,19 +238,19 @@
           if List.exists l ~f:matches
           then [lid_of_id id, Pconstructor]
           else []
-      | Tsig_module (id, Tmty_signature sign) ->
+      | Tsig_module (id, Tmty_signature sign, _) ->
           search_type_in_signature t ~sign ~mode
             ~prefix:(prefix @ [Ident.name id])
       | Tsig_module _ -> []
       | Tsig_modtype _ -> []
-      | Tsig_class (id, cl) ->
+      | Tsig_class (id, cl, _) ->
           let self = self_type cl.cty_type in
           if matches self
           || (match cl.cty_new with None -> false | Some ty -> matches ty)
           (* || List.exists (get_fields ~prefix ~sign self)
               ~f:(fun (_,_,ty_field) -> matches ty_field) *)
           then [lid_of_id id, Pclass] else []
-      | Tsig_cltype (id, cl) ->
+      | Tsig_cltype (id, cl, _) ->
           let self = self_type cl.clty_type in
           if matches self
           (* || List.exists (get_fields ~prefix ~sign self)
@@ -354,16 +354,16 @@
         List2.flat_map sign ~f:
           begin function
             Tsig_value (i, _) when check i -> [i, Pvalue]
-          | Tsig_type (i, _) when check i -> [i, Ptype]
+          | Tsig_type (i, _, _) when check i -> [i, Ptype]
           | Tsig_exception (i, _) when check i -> [i, Pconstructor]
-          | Tsig_module (i, _) when check i -> [i, Pmodule]
+          | Tsig_module (i, _, _) when check i -> [i, Pmodule]
           | Tsig_modtype (i, _) when check i -> [i, Pmodtype]
-          | Tsig_class (i, cl) when check i
+          | Tsig_class (i, cl, _) when check i
             || List.exists
                 (get_fields ~prefix:[modname] ~sign (self_type cl.cty_type))
                 ~f:(fun (name,_,_) -> check_match ~pattern (explode name))
             -> [i, Pclass]
-          | Tsig_cltype (i, cl) when check i
+          | Tsig_cltype (i, cl, _) when check i
             || List.exists
                 (get_fields ~prefix:[modname] ~sign (self_type cl.clty_type))
                 ~f:(fun (name,_,_) -> check_match ~pattern (explode name))
Index: otherlibs/labltk/browser/searchpos.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/otherlibs/labltk/browser/searchpos.ml,v
retrieving revision 1.43
diff -u -r1.43 searchpos.ml
--- otherlibs/labltk/browser/searchpos.ml	13 Jan 2004 05:58:47 -0000	1.43
+++ otherlibs/labltk/browser/searchpos.ml	17 May 2004 12:06:39 -0000
@@ -290,12 +290,12 @@
       let id, kind =
         match item with
           Tsig_value (id, _) -> id, Pvalue
-        | Tsig_type (id, _) -> id, Ptype
+        | Tsig_type (id, _, _) -> id, Ptype
         | Tsig_exception (id, _) -> id, Pconstructor
-        | Tsig_module (id, _) -> id, Pmodule
+        | Tsig_module (id, _, _) -> id, Pmodule
         | Tsig_modtype (id, _) -> id, Pmodtype
-        | Tsig_class (id, _) -> id, Pclass
-        | Tsig_cltype (id, _) -> id, Pcltype
+        | Tsig_class (id, _, _) -> id, Pclass
+        | Tsig_cltype (id, _, _) -> id, Pcltype
       in
       let prefix = List.tl (list_of_path path) and name = Ident.name id in
       let pos =
@@ -438,7 +438,7 @@
       !view_defined_ref (Searchid.longident_of_path path) ~env
   | modtype ->
       let id = ident_of_path path ~default:"M" in
-      view_signature_item [Tsig_module (id, modtype)] ~path ~env
+      view_signature_item [Tsig_module (id, modtype, Trec_not)] ~path ~env
 
 and view_module_id id ~env =
   let path, _ = lookup_module id env in
@@ -451,11 +451,11 @@
         {desc = Tobject _} ->
           let clt = find_cltype path env in
           view_signature_item ~path ~env
-            [Tsig_cltype(ident_of_path path ~default:"ct", clt)]
+            [Tsig_cltype(ident_of_path path ~default:"ct", clt, Trec_first)]
       | _ -> raise Not_found
   with Not_found ->
     view_signature_item ~path ~env
-      [Tsig_type(ident_of_path path ~default:"t", td)]
+      [Tsig_type(ident_of_path path ~default:"t", td, Trec_first)]
 
 and view_type_id li ~env =
   let path, decl = lookup_type li env in
@@ -464,12 +464,12 @@
 and view_class_id li ~env =
   let path, cl = lookup_class li env in
   view_signature_item ~path ~env
-     [Tsig_class(ident_of_path path ~default:"c", cl)]
+     [Tsig_class(ident_of_path path ~default:"c", cl, Trec_first)]
 
 and view_cltype_id li ~env =
   let path, clt = lookup_cltype li env in
   view_signature_item ~path ~env
-     [Tsig_cltype(ident_of_path path ~default:"ct", clt)]
+     [Tsig_cltype(ident_of_path path ~default:"ct", clt, Trec_first)]
 
 and view_modtype_id li ~env =
   let path, td = lookup_modtype li env in
@@ -576,19 +576,19 @@
       | `New path ->
           let cl = find_class path env in
           view_signature_item ~path ~env
-            [Tsig_class(ident_of_path path ~default:"c", cl)]
+            [Tsig_class(ident_of_path path ~default:"c", cl, Trec_first)]
       end
   | `Class (path, cty) ->
       let cld = { cty_params = []; cty_type = cty;
                   cty_path = path; cty_new = None } in
       view_signature_item ~path ~env
-        [Tsig_class(ident_of_path path ~default:"c", cld)]
+        [Tsig_class(ident_of_path path ~default:"c", cld, Trec_first)]
   | `Module (path, mty) ->
       match mty with
         Tmty_signature sign -> view_signature sign ~path ~env
       | modtype ->
           view_signature_item ~path ~env
-            [Tsig_module(ident_of_path path ~default:"M", mty)]
+            [Tsig_module(ident_of_path path ~default:"M", mty, Trec_not)]
 
 let view_type_menu kind ~env ~parent =
   let title =
Index: otherlibs/labltk/browser/viewer.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/otherlibs/labltk/browser/viewer.ml,v
retrieving revision 1.30
diff -u -r1.30 viewer.ml
--- otherlibs/labltk/browser/viewer.ml	9 Aug 2002 10:34:44 -0000	1.30
+++ otherlibs/labltk/browser/viewer.ml	17 May 2004 12:06:39 -0000
@@ -218,12 +218,12 @@
 
 let ident_of_decl ~modlid = function
     Tsig_value (id, _) -> Lident (Ident.name id), Pvalue
-  | Tsig_type (id, _) -> Lident (Ident.name id), Ptype
+  | Tsig_type (id, _, _) -> Lident (Ident.name id), Ptype
   | Tsig_exception (id, _) -> Ldot (modlid, Ident.name id), Pconstructor
-  | Tsig_module (id, _) -> Lident (Ident.name id), Pmodule
+  | Tsig_module (id, _, _) -> Lident (Ident.name id), Pmodule
   | Tsig_modtype (id, _) -> Lident (Ident.name id), Pmodtype
-  | Tsig_class (id, _) -> Lident (Ident.name id), Pclass
-  | Tsig_cltype (id, _) -> Lident (Ident.name id), Pcltype
+  | Tsig_class (id, _, _) -> Lident (Ident.name id), Pclass
+  | Tsig_cltype (id, _, _) -> Lident (Ident.name id), Pcltype
 
 let view_defined ~env ?(show_all=false) modlid =
   try match lookup_module modlid env with path, Tmty_signature sign ->
Index: toplevel/toploop.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/toplevel/toploop.ml,v
retrieving revision 1.86
diff -u -r1.86 toploop.ml
--- toplevel/toploop.ml	15 May 2004 09:59:37 -0000	1.86
+++ toplevel/toploop.ml	17 May 2004 11:55:02 -0000
@@ -162,23 +162,23 @@
             Some v
       in
       Some (tree, valopt, rem)
-  | Tsig_type(id, decl) :: rem ->
-      let tree = Printtyp.tree_of_type_declaration id decl in
+  | Tsig_type(id, decl, rs) :: rem ->
+      let tree = Printtyp.tree_of_type_declaration id decl rs in
       Some (tree, None, rem)
   | Tsig_exception(id, decl) :: rem ->
       let tree = Printtyp.tree_of_exception_declaration id decl in
       Some (tree, None, rem)
-  | Tsig_module(id, mty) :: rem ->
-      let tree = Printtyp.tree_of_module id mty in
+  | Tsig_module(id, mty, rs) :: rem ->
+      let tree = Printtyp.tree_of_module id mty rs in
       Some (tree, None, rem)
   | Tsig_modtype(id, decl) :: rem ->
       let tree = Printtyp.tree_of_modtype_declaration id decl in
       Some (tree, None, rem)
-  | Tsig_class(id, decl) :: cltydecl :: tydecl1 :: tydecl2 :: rem ->
-      let tree = Printtyp.tree_of_class_declaration id decl in
+  | Tsig_class(id, decl, rs) :: cltydecl :: tydecl1 :: tydecl2 :: rem ->
+      let tree = Printtyp.tree_of_class_declaration id decl rs in
       Some (tree, None, rem)
-  | Tsig_cltype(id, decl) :: tydecl1 :: tydecl2 :: rem ->
-      let tree = Printtyp.tree_of_cltype_declaration id decl in
+  | Tsig_cltype(id, decl, rs) :: tydecl1 :: tydecl2 :: rem ->
+      let tree = Printtyp.tree_of_cltype_declaration id decl rs in
       Some (tree, None, rem)
   | _ -> None
 
Index: typing/env.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/env.ml,v
retrieving revision 1.53
diff -u -r1.53 env.ml
--- typing/env.ml	25 Nov 2003 09:20:42 -0000	1.53
+++ typing/env.ml	17 May 2004 11:49:14 -0000
@@ -420,7 +420,7 @@
       let nextpos = match decl.val_kind with Val_prim _ -> pos | _ -> pos+1 in
       let (pl, final_sub) = prefix_idents root nextpos sub rem in
       (p::pl, final_sub)
-  | Tsig_type(id, decl) :: rem ->
+  | Tsig_type(id, decl, _) :: rem ->
       let p = Pdot(root, Ident.name id, nopos) in
       let (pl, final_sub) =
         prefix_idents root pos (Subst.add_type id p sub) rem in
@@ -429,7 +429,7 @@
       let p = Pdot(root, Ident.name id, pos) in
       let (pl, final_sub) = prefix_idents root (pos+1) sub rem in
       (p::pl, final_sub)
-  | Tsig_module(id, mty) :: rem ->
+  | Tsig_module(id, mty, _) :: rem ->
       let p = Pdot(root, Ident.name id, pos) in
       let (pl, final_sub) =
         prefix_idents root (pos+1) (Subst.add_module id p sub) rem in
@@ -440,11 +440,11 @@
         prefix_idents root pos
                       (Subst.add_modtype id (Tmty_ident p) sub) rem in
       (p::pl, final_sub)
-  | Tsig_class(id, decl) :: rem ->
+  | Tsig_class(id, decl, _) :: rem ->
       let p = Pdot(root, Ident.name id, pos) in
       let (pl, final_sub) = prefix_idents root (pos + 1) sub rem in
       (p::pl, final_sub)
-  | Tsig_cltype(id, decl) :: rem ->
+  | Tsig_cltype(id, decl, _) :: rem ->
       let p = Pdot(root, Ident.name id, nopos) in
       let (pl, final_sub) = prefix_idents root pos sub rem in
       (p::pl, final_sub)
@@ -472,7 +472,7 @@
             begin match decl.val_kind with
               Val_prim _ -> () | _ -> incr pos
             end
-        | Tsig_type(id, decl) ->
+        | Tsig_type(id, decl, _) ->
             let decl' = Subst.type_declaration sub decl in
             c.comp_types <-
               Tbl.add (Ident.name id) (decl', nopos) c.comp_types;
@@ -491,7 +491,7 @@
             c.comp_constrs <-
               Tbl.add (Ident.name id) (cstr, !pos) c.comp_constrs;
             incr pos
-        | Tsig_module(id, mty) ->
+        | Tsig_module(id, mty, _) ->
             let mty' = Subst.modtype sub mty in
             c.comp_modules <-
               Tbl.add (Ident.name id) (mty', !pos) c.comp_modules;
@@ -505,12 +505,12 @@
             c.comp_modtypes <-
               Tbl.add (Ident.name id) (decl', nopos) c.comp_modtypes;
             env := store_modtype id path decl !env
-        | Tsig_class(id, decl) ->
+        | Tsig_class(id, decl, _) ->
             let decl' = Subst.class_declaration sub decl in
             c.comp_classes <-
               Tbl.add (Ident.name id) (decl', !pos) c.comp_classes;
             incr pos
-        | Tsig_cltype(id, decl) ->
+        | Tsig_cltype(id, decl, _) ->
             let decl' = Subst.cltype_declaration sub decl in
             c.comp_cltypes <-
               Tbl.add (Ident.name id) (decl', !pos) c.comp_cltypes)
@@ -652,12 +652,12 @@
 let add_item comp env =
   match comp with
     Tsig_value(id, decl)     -> add_value id decl env
-  | Tsig_type(id, decl)      -> add_type id decl env
+  | Tsig_type(id, decl, _)   -> add_type id decl env
   | Tsig_exception(id, decl) -> add_exception id decl env
-  | Tsig_module(id, mty)     -> add_module id mty env
+  | Tsig_module(id, mty, _)  -> add_module id mty env
   | Tsig_modtype(id, decl)   -> add_modtype id decl env
-  | Tsig_class(id, decl)     -> add_class id decl env
-  | Tsig_cltype(id, decl)    -> add_cltype id decl env
+  | Tsig_class(id, decl, _)  -> add_class id decl env
+  | Tsig_cltype(id, decl, _) -> add_cltype id decl env
 
 let rec add_signature sg env =
   match sg with
@@ -677,21 +677,21 @@
           Tsig_value(id, decl) ->
             store_value (Ident.hide id) p
                         (Subst.value_description sub decl) env
-        | Tsig_type(id, decl) ->
+        | Tsig_type(id, decl, _) ->
             store_type (Ident.hide id) p
                        (Subst.type_declaration sub decl) env
         | Tsig_exception(id, decl) ->
             store_exception (Ident.hide id) p
                             (Subst.exception_declaration sub decl) env
-        | Tsig_module(id, mty) ->
+        | Tsig_module(id, mty, _) ->
             store_module (Ident.hide id) p (Subst.modtype sub mty) env
         | Tsig_modtype(id, decl) ->
             store_modtype (Ident.hide id) p
                           (Subst.modtype_declaration sub decl) env
-        | Tsig_class(id, decl) ->
+        | Tsig_class(id, decl, _) ->
             store_class (Ident.hide id) p
                         (Subst.class_declaration sub decl) env
-        | Tsig_cltype(id, decl) ->
+        | Tsig_cltype(id, decl, _) ->
             store_cltype (Ident.hide id) p
                          (Subst.cltype_declaration sub decl) env)
       env sg pl in
Index: typing/includemod.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/includemod.ml,v
retrieving revision 1.32
diff -u -r1.32 includemod.ml
--- typing/includemod.ml	27 Jul 2003 17:02:33 -0000	1.32
+++ typing/includemod.ml	17 May 2004 09:48:27 -0000
@@ -104,12 +104,12 @@
 
 let item_ident_name = function
     Tsig_value(id, _) -> (id, Field_value(Ident.name id))
-  | Tsig_type(id, _) -> (id, Field_type(Ident.name id))
+  | Tsig_type(id, _, _) -> (id, Field_type(Ident.name id))
   | Tsig_exception(id, _) -> (id, Field_exception(Ident.name id))
-  | Tsig_module(id, _) -> (id, Field_module(Ident.name id))
+  | Tsig_module(id, _, _) -> (id, Field_module(Ident.name id))
   | Tsig_modtype(id, _) -> (id, Field_modtype(Ident.name id))
-  | Tsig_class(id, _) -> (id, Field_class(Ident.name id))
-  | Tsig_cltype(id, _) -> (id, Field_classtype(Ident.name id))
+  | Tsig_class(id, _, _) -> (id, Field_class(Ident.name id))
+  | Tsig_cltype(id, _, _) -> (id, Field_classtype(Ident.name id))
 
 (* Simplify a structure coercion *)
 
@@ -184,13 +184,13 @@
         let nextpos =
           match item with
             Tsig_value(_,{val_kind = Val_prim _})
-          | Tsig_type(_,_)
+          | Tsig_type(_,_,_)
           | Tsig_modtype(_,_)
-          | Tsig_cltype(_,_) -> pos
+          | Tsig_cltype(_,_,_) -> pos
           | Tsig_value(_,_)
           | Tsig_exception(_,_)
-          | Tsig_module(_,_)
-          | Tsig_class(_, _) -> pos+1 in
+          | Tsig_module(_,_,_)
+          | Tsig_class(_, _,_) -> pos+1 in
         build_component_table nextpos
                               (Tbl.add name (id, item, pos) tbl) rem in
   let comps1 =
@@ -239,24 +239,24 @@
         Val_prim p -> signature_components env subst rem
       | _ -> (pos, cc) :: signature_components env subst rem
       end
-  | (Tsig_type(id1, tydecl1), Tsig_type(id2, tydecl2), pos) :: rem ->
+  | (Tsig_type(id1, tydecl1, _), Tsig_type(id2, tydecl2, _), pos) :: rem ->
       type_declarations env subst id1 tydecl1 tydecl2;
       signature_components env subst rem
   | (Tsig_exception(id1, excdecl1), Tsig_exception(id2, excdecl2), pos)
     :: rem ->
       exception_declarations env subst id1 excdecl1 excdecl2;
       (pos, Tcoerce_none) :: signature_components env subst rem
-  | (Tsig_module(id1, mty1), Tsig_module(id2, mty2), pos) :: rem ->
+  | (Tsig_module(id1, mty1, _), Tsig_module(id2, mty2, _), pos) :: rem ->
       let cc =
         modtypes env subst (Mtype.strengthen env mty1 (Pident id1)) mty2 in
       (pos, cc) :: signature_components env subst rem
   | (Tsig_modtype(id1, info1), Tsig_modtype(id2, info2), pos) :: rem ->
       modtype_infos env subst id1 info1 info2;
       signature_components env subst rem
-  | (Tsig_class(id1, decl1), Tsig_class(id2, decl2), pos) :: rem ->
+  | (Tsig_class(id1, decl1, _), Tsig_class(id2, decl2, _), pos) :: rem ->
       class_declarations env subst id1 decl1 decl2;
       (pos, Tcoerce_none) :: signature_components env subst rem
-  | (Tsig_cltype(id1, info1), Tsig_cltype(id2, info2), pos) :: rem ->
+  | (Tsig_cltype(id1, info1, _), Tsig_cltype(id2, info2, _), pos) :: rem ->
       class_type_declarations env subst id1 info1 info2;
       signature_components env subst rem
   | _ ->
Index: typing/mtype.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/mtype.ml,v
retrieving revision 1.24
diff -u -r1.24 mtype.ml
--- typing/mtype.ml	9 Apr 2004 13:32:28 -0000	1.24
+++ typing/mtype.ml	17 May 2004 09:48:27 -0000
@@ -45,7 +45,7 @@
     [] -> []
   | (Tsig_value(id, desc) as sigelt) :: rem ->
       sigelt :: strengthen_sig env rem p
-  | Tsig_type(id, decl) :: rem ->
+  | Tsig_type(id, decl, rs) :: rem ->
       let newdecl =
         match decl.type_manifest with
           None ->
@@ -53,12 +53,12 @@
                 Some(Btype.newgenty(Tconstr(Pdot(p, Ident.name id, nopos),
                                             decl.type_params, ref Mnil))) }
         | _ -> decl in
-      Tsig_type(id, newdecl) :: strengthen_sig env rem p
+      Tsig_type(id, newdecl, rs) :: strengthen_sig env rem p
   | (Tsig_exception(id, d) as sigelt) :: rem ->
       sigelt :: strengthen_sig env rem p
-  | Tsig_module(id, mty) :: rem ->
-      Tsig_module(id, strengthen env mty (Pdot(p, Ident.name id, nopos))) ::
-      strengthen_sig (Env.add_module id mty env) rem p
+  | Tsig_module(id, mty, rs) :: rem ->
+      Tsig_module(id, strengthen env mty (Pdot(p, Ident.name id, nopos)), rs)
+      :: strengthen_sig (Env.add_module id mty env) rem p
       (* Need to add the module in case it defines manifest module types *)
   | Tsig_modtype(id, decl) :: rem ->
       let newdecl =
@@ -70,9 +70,9 @@
       Tsig_modtype(id, newdecl) ::
       strengthen_sig (Env.add_modtype id decl env) rem p
       (* Need to add the module type in case it is manifest *)
-  | (Tsig_class(id, decl) as sigelt) :: rem ->
+  | (Tsig_class(id, decl, rs) as sigelt) :: rem ->
       sigelt :: strengthen_sig env rem p
-  | (Tsig_cltype(id, decl) as sigelt) :: rem ->
+  | (Tsig_cltype(id, decl, rs) as sigelt) :: rem ->
       sigelt :: strengthen_sig env rem p
 
 (* In nondep_supertype, env is only used for the type it assigns to id.
@@ -104,12 +104,13 @@
         Tsig_value(id, d) ->
           Tsig_value(id, {val_type = Ctype.nondep_type env mid d.val_type;
                           val_kind = d.val_kind}) :: rem'
-      | Tsig_type(id, d) ->
-          Tsig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d) :: rem'
+      | Tsig_type(id, d, rs) ->
+          Tsig_type(id, Ctype.nondep_type_decl env mid id (va = Co) d, rs)
+          :: rem'
       | Tsig_exception(id, d) ->
           Tsig_exception(id, List.map (Ctype.nondep_type env mid) d) :: rem'
-      | Tsig_module(id, mty) ->
-          Tsig_module(id, nondep_mty va mty) :: rem'
+      | Tsig_module(id, mty, rs) ->
+          Tsig_module(id, nondep_mty va mty, rs) :: rem'
       | Tsig_modtype(id, d) ->
           begin try
             Tsig_modtype(id, nondep_modtype_decl d) :: rem'
@@ -118,10 +119,12 @@
               Co -> Tsig_modtype(id, Tmodtype_abstract) :: rem'
             | _  -> raise Not_found
           end
-      | Tsig_class(id, d) ->
-          Tsig_class(id, Ctype.nondep_class_declaration env mid d) :: rem'
-      | Tsig_cltype(id, d) ->
-          Tsig_cltype(id, Ctype.nondep_cltype_declaration env mid d) :: rem'
+      | Tsig_class(id, d, rs) ->
+          Tsig_class(id, Ctype.nondep_class_declaration env mid d, rs)
+          :: rem'
+      | Tsig_cltype(id, d, rs) ->
+          Tsig_cltype(id, Ctype.nondep_cltype_declaration env mid d, rs)
+          :: rem'
 
   and nondep_modtype_decl = function
       Tmodtype_abstract -> Tmodtype_abstract
@@ -151,10 +154,12 @@
       mty
 
 and enrich_item env p = function
-    Tsig_type(id, decl) ->
-      Tsig_type(id, enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl)
-  | Tsig_module(id, mty) ->
-      Tsig_module(id, enrich_modtype env (Pdot(p, Ident.name id, nopos)) mty)
+    Tsig_type(id, decl, rs) ->
+      Tsig_type(id,
+                enrich_typedecl env (Pdot(p, Ident.name id, nopos)) decl, rs)
+  | Tsig_module(id, mty, rs) ->
+      Tsig_module(id,
+                  enrich_modtype env (Pdot(p, Ident.name id, nopos)) mty, rs)
   | item -> item
 
 let rec type_paths env p mty =
@@ -169,9 +174,9 @@
   | Tsig_value(id, decl) :: rem ->
       let pos' = match decl.val_kind with Val_prim _ -> pos | _ -> pos + 1 in
       type_paths_sig env p pos' rem
-  | Tsig_type(id, decl) :: rem ->
+  | Tsig_type(id, decl, _) :: rem ->
       Pdot(p, Ident.name id, nopos) :: type_paths_sig env p pos rem
-  | Tsig_module(id, mty) :: rem ->
+  | Tsig_module(id, mty, _) :: rem ->
       type_paths env (Pdot(p, Ident.name id, pos)) mty @
       type_paths_sig (Env.add_module id mty env) p (pos+1) rem
   | Tsig_modtype(id, decl) :: rem ->
@@ -195,7 +200,7 @@
       | Val_prim _ -> no_code_needed_sig env rem
       | _ -> false
       end
-  | Tsig_module(id, mty) :: rem ->
+  | Tsig_module(id, mty, _) :: rem ->
       no_code_needed env mty &&
       no_code_needed_sig (Env.add_module id mty env) rem
   | (Tsig_type _ | Tsig_modtype _ | Tsig_cltype _) :: rem ->
Index: typing/oprint.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/oprint.ml,v
retrieving revision 1.18
diff -u -r1.18 oprint.ml
--- typing/oprint.ml	29 Jul 2003 09:11:13 -0000	1.18
+++ typing/oprint.ml	17 May 2004 11:49:06 -0000
@@ -317,12 +317,14 @@
       fprintf ppf "%a@ %a" !out_sig_item item print_out_signature items
 and print_out_sig_item ppf =
   function
-    Osig_class (vir_flag, name, params, clt) ->
-      fprintf ppf "@[<2>class%s@ %a%s@ :@ %a@]"
+    Osig_class (vir_flag, name, params, clt, rs) ->
+      fprintf ppf "@[<2>%s%s@ %a%s@ :@ %a@]"
+        (if rs = Orec_next then "and" else "class")
         (if vir_flag then " virtual" else "") print_out_class_params params
         name !out_class_type clt
-  | Osig_class_type (vir_flag, name, params, clt) ->
-      fprintf ppf "@[<2>class type%s@ %a%s@ =@ %a@]"
+  | Osig_class_type (vir_flag, name, params, clt, rs) ->
+      fprintf ppf "@[<2>%s%s@ %a%s@ =@ %a@]"
+        (if rs = Orec_next then "and" else "class type")
         (if vir_flag then " virtual" else "") print_out_class_params params
         name !out_class_type clt
   | Osig_exception (id, tyl) ->
@@ -331,9 +333,16 @@
       fprintf ppf "@[<2>module type %s@]" name
   | Osig_modtype (name, mty) ->
       fprintf ppf "@[<2>module type %s =@ %a@]" name !out_module_type mty
-  | Osig_module (name, mty) ->
-      fprintf ppf "@[<2>module %s :@ %a@]" name !out_module_type mty
-  | Osig_type tdl -> print_out_type_decl_list ppf tdl
+  | Osig_module (name, mty, rs) ->
+      fprintf ppf "@[<2>%s %s :@ %a@]" 
+        (match rs with Orec_not -> "module"
+                     | Orec_first -> "module rec"
+                     | Orec_next -> "and")
+        name !out_module_type mty
+  | Osig_type(td, rs) ->
+        print_out_type_decl
+          (if rs = Orec_next then "and" else "type")
+          ppf td
   | Osig_value (name, ty, prims) ->
       let kwd = if prims = [] then "val" else "external" in
       let pr_prims ppf =
@@ -345,13 +354,7 @@
       in
       fprintf ppf "@[<2>%s %a :@ %a%a@]" kwd value_ident name !out_type
         ty pr_prims prims
-and print_out_type_decl_list ppf =
-  function
-    [] -> ()
-  | [x] -> print_out_type_decl "type" ppf x
-  | x :: l ->
-      print_out_type_decl "type" ppf x;
-      List.iter (fun x -> fprintf ppf "@ %a" (print_out_type_decl "and") x) l
+
 and print_out_type_decl kwd ppf (name, args, ty, constraints) =
   let print_constraints ppf params =
     List.iter
Index: typing/outcometree.mli
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/outcometree.mli,v
retrieving revision 1.11
diff -u -r1.11 outcometree.mli
--- typing/outcometree.mli	2 Jul 2003 09:14:33 -0000	1.11
+++ typing/outcometree.mli	17 May 2004 09:24:31 -0000
@@ -79,16 +79,22 @@
   | Omty_ident of out_ident
   | Omty_signature of out_sig_item list
 and out_sig_item =
-  | Osig_class of bool * string * string list * out_class_type
-  | Osig_class_type of bool * string * string list * out_class_type
+  | Osig_class of
+      bool * string * string list * out_class_type * out_rec_status
+  | Osig_class_type of
+      bool * string * string list * out_class_type * out_rec_status
   | Osig_exception of string * out_type list
   | Osig_modtype of string * out_module_type
-  | Osig_module of string * out_module_type
-  | Osig_type of out_type_decl list
+  | Osig_module of string * out_module_type * out_rec_status
+  | Osig_type of out_type_decl * out_rec_status
   | Osig_value of string * out_type * string list
 and out_type_decl =
   string * (string * (bool * bool)) list * out_type *
   (out_type * out_type) list
+and out_rec_status =
+  | Orec_not
+  | Orec_first
+  | Orec_next
 
 type out_phrase =
   | Ophr_eval of out_value * out_type
Index: typing/printtyp.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/printtyp.ml,v
retrieving revision 1.129
diff -u -r1.129 printtyp.ml
--- typing/printtyp.ml	27 Apr 2004 07:37:30 -0000	1.129
+++ typing/printtyp.ml	17 May 2004 11:55:23 -0000
@@ -69,6 +69,13 @@
   | Papply(p1, p2) ->
       fprintf ppf "%a(%a)" path p1 path p2
 
+(* Print a recursive annotation *)
+
+let tree_of_rec = function
+  | Trec_not -> Orec_not
+  | Trec_first -> Orec_first
+  | Trec_next -> Orec_next
+
 (* Print a raw type expression, with sharing *)
 
 let raw_list pr ppf = function
@@ -578,11 +585,11 @@
 and tree_of_label (name, mut, arg) =
   (name, mut = Mutable, tree_of_typexp false arg)
 
-let tree_of_type_declaration id decl =
-  Osig_type [tree_of_type_decl id decl]
+let tree_of_type_declaration id decl rs =
+  Osig_type (tree_of_type_decl id decl, tree_of_rec rs)
 
 let type_declaration id ppf decl =
-  !Oprint.out_sig_item ppf (tree_of_type_declaration id decl)
+  !Oprint.out_sig_item ppf (tree_of_type_declaration id decl Trec_first)
 
 (* Print an exception declaration *)
 
@@ -712,7 +719,7 @@
       let tyl = tree_of_typlist true params in
       List.map (function Otyp_var (_, s) -> s | _ -> "?") tyl
 
-let tree_of_class_declaration id cl =
+let tree_of_class_declaration id cl rs =
   let params = filter_params cl.cty_params in
 
   reset ();
@@ -727,12 +734,13 @@
   let vir_flag = cl.cty_new = None in
   Osig_class
     (vir_flag, Ident.name id, tree_of_class_params params,
-     tree_of_class_type true params cl.cty_type)
+     tree_of_class_type true params cl.cty_type,
+     tree_of_rec rs)
 
 let class_declaration id ppf cl =
-  !Oprint.out_sig_item ppf (tree_of_class_declaration id cl)
+  !Oprint.out_sig_item ppf (tree_of_class_declaration id cl Trec_first)
 
-let tree_of_cltype_declaration id cl =
+let tree_of_cltype_declaration id cl rs =
   let params = List.map repr cl.clty_params in
 
   reset ();
@@ -756,10 +764,11 @@
 
   Osig_class_type
     (virt, Ident.name id, tree_of_class_params params,
-     tree_of_class_type true params cl.clty_type)
+     tree_of_class_type true params cl.clty_type,
+     tree_of_rec rs)
 
 let cltype_declaration id ppf cl =
-  !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl)
+  !Oprint.out_sig_item ppf (tree_of_cltype_declaration id cl Trec_first)
 
 (* Print a module type *)
 
@@ -774,48 +783,25 @@
 
 and tree_of_signature = function
   | [] -> []
-  | item :: rem ->
-      match item with
-      | Tsig_value(id, decl) ->
-          tree_of_value_description id decl :: tree_of_signature rem
-      | Tsig_type(id, decl)  ->
-          let (type_decl_list, rem) =
-            let rec more_type_declarations = function
-            | Tsig_type(id, decl) :: rem ->
-                let (type_decl_list, rem) = more_type_declarations rem in
-                (id, decl) :: type_decl_list, rem
-            | rem -> [], rem in
-            more_type_declarations rem
-          in
-          let type_decl_list =
-            List.map (fun (id, decl) -> tree_of_type_decl id decl)
-              ((id, decl) :: type_decl_list)
-          in
-          Osig_type type_decl_list
-          ::
-          tree_of_signature rem
-      | Tsig_exception(id, decl)  ->
-          Osig_exception (Ident.name id, tree_of_typlist false decl) ::
-          tree_of_signature rem
-      | Tsig_module(id, mty)  ->
-          Osig_module (Ident.name id, tree_of_modtype mty) ::
-          tree_of_signature rem
-      | Tsig_modtype(id, decl)  ->
-          tree_of_modtype_declaration id decl :: tree_of_signature rem
-      | Tsig_class(id, decl) ->
-          let rem =
-            match rem with
-            | ctydecl :: tydecl1 :: tydecl2 :: rem -> rem
-            | _ -> []
-          in
-          tree_of_class_declaration id decl :: tree_of_signature rem
-      | Tsig_cltype(id, decl) ->
-          let rem =
-            match rem with
-            | tydecl1 :: tydecl2 :: rem -> rem
-            | _ -> []
-          in
-          tree_of_cltype_declaration id decl :: tree_of_signature rem
+  | Tsig_value(id, decl) :: rem ->
+      tree_of_value_description id decl :: tree_of_signature rem
+  | Tsig_type(id, decl, rs) :: rem ->
+      Osig_type(tree_of_type_decl id decl, tree_of_rec rs) ::
+      tree_of_signature rem
+  | Tsig_exception(id, decl) :: rem ->
+      Osig_exception (Ident.name id, tree_of_typlist false decl) ::
+      tree_of_signature rem
+  | Tsig_module(id, mty, rs) :: rem ->
+      Osig_module (Ident.name id, tree_of_modtype mty, tree_of_rec rs) ::
+      tree_of_signature rem
+  | Tsig_modtype(id, decl) :: rem ->
+      tree_of_modtype_declaration id decl :: tree_of_signature rem
+  | Tsig_class(id, decl, rs) :: ctydecl :: tydecl1 :: tydecl2 :: rem ->
+      tree_of_class_declaration id decl rs :: tree_of_signature rem
+  | Tsig_cltype(id, decl, rs) :: tydecl1 :: tydecl2 :: rem ->
+      tree_of_cltype_declaration id decl rs :: tree_of_signature rem
+  | _ ->
+      assert false
 
 and tree_of_modtype_declaration id decl =
   let mty =
@@ -825,7 +811,8 @@
   in
   Osig_modtype (Ident.name id, mty)
 
-let tree_of_module id mty = Osig_module (Ident.name id, tree_of_modtype mty)
+let tree_of_module id mty rs = 
+  Osig_module (Ident.name id, tree_of_modtype mty, tree_of_rec rs)
 
 let modtype ppf mty = !Oprint.out_module_type ppf (tree_of_modtype mty)
 let modtype_declaration id ppf decl =
Index: typing/printtyp.mli
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/printtyp.mli,v
retrieving revision 1.25
diff -u -r1.25 printtyp.mli
--- typing/printtyp.mli	7 Nov 2003 01:07:32 -0000	1.25
+++ typing/printtyp.mli	17 May 2004 11:55:05 -0000
@@ -37,19 +37,19 @@
 (* Fin Maxence *)
 val tree_of_value_description: Ident.t -> value_description -> out_sig_item
 val value_description: Ident.t -> formatter -> value_description -> unit
-val tree_of_type_declaration: Ident.t -> type_declaration -> out_sig_item
+val tree_of_type_declaration: Ident.t -> type_declaration -> rec_status -> out_sig_item
 val type_declaration: Ident.t -> formatter -> type_declaration -> unit
 val tree_of_exception_declaration: Ident.t -> exception_declaration -> out_sig_item
 val exception_declaration: Ident.t -> formatter -> exception_declaration -> unit
-val tree_of_module: Ident.t -> module_type -> out_sig_item
+val tree_of_module: Ident.t -> module_type -> rec_status -> out_sig_item
 val modtype: formatter -> module_type -> unit
 val signature: formatter -> signature -> unit
 val tree_of_modtype_declaration: Ident.t -> modtype_declaration -> out_sig_item
 val modtype_declaration: Ident.t -> formatter -> modtype_declaration -> unit
 val class_type: formatter -> class_type -> unit
-val tree_of_class_declaration: Ident.t -> class_declaration -> out_sig_item
+val tree_of_class_declaration: Ident.t -> class_declaration -> rec_status -> out_sig_item
 val class_declaration: Ident.t -> formatter -> class_declaration -> unit
-val tree_of_cltype_declaration: Ident.t -> cltype_declaration -> out_sig_item
+val tree_of_cltype_declaration: Ident.t -> cltype_declaration -> rec_status -> out_sig_item
 val cltype_declaration: Ident.t -> formatter -> cltype_declaration -> unit
 val type_expansion: type_expr -> Format.formatter -> type_expr -> unit
 val prepare_expansion: type_expr * type_expr -> type_expr * type_expr
Index: typing/subst.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/subst.ml,v
retrieving revision 1.44
diff -u -r1.44 subst.ml
--- typing/subst.ml	22 Jul 2003 10:58:39 -0000	1.44
+++ typing/subst.ml	17 May 2004 09:48:27 -0000
@@ -233,10 +233,10 @@
 
 let rec rename_bound_idents s idents = function
     [] -> (List.rev idents, s)
-  | Tsig_type(id, d) :: sg ->
+  | Tsig_type(id, d, _) :: sg ->
       let id' = Ident.rename id in
       rename_bound_idents (add_type id (Pident id') s) (id' :: idents) sg
-  | Tsig_module(id, mty) :: sg ->
+  | Tsig_module(id, mty, _) :: sg ->
       let id' = Ident.rename id in
       rename_bound_idents (add_module id (Pident id') s) (id' :: idents) sg
   | Tsig_modtype(id, d) :: sg ->
@@ -244,7 +244,7 @@
       rename_bound_idents (add_modtype id (Tmty_ident(Pident id')) s)
                           (id' :: idents) sg
   | (Tsig_value(id, _) | Tsig_exception(id, _) | 
-     Tsig_class(id, _) | Tsig_cltype(id, _)) :: sg ->
+     Tsig_class(id, _, _) | Tsig_cltype(id, _, _)) :: sg ->
       let id' = Ident.rename id in
       rename_bound_idents s (id' :: idents) sg
 
@@ -277,18 +277,18 @@
   match comp with
     Tsig_value(id, d) ->
       Tsig_value(newid, value_description s d)
-  | Tsig_type(id, d) ->
-      Tsig_type(newid, type_declaration s d)
+  | Tsig_type(id, d, rs) ->
+      Tsig_type(newid, type_declaration s d, rs)
   | Tsig_exception(id, d) ->
       Tsig_exception(newid, exception_declaration s d)
-  | Tsig_module(id, mty) ->
-      Tsig_module(newid, modtype s mty)
+  | Tsig_module(id, mty, rs) ->
+      Tsig_module(newid, modtype s mty, rs)
   | Tsig_modtype(id, d) ->
       Tsig_modtype(newid, modtype_declaration s d)
-  | Tsig_class(id, d) ->
-      Tsig_class(newid, class_declaration s d)
-  | Tsig_cltype(id, d) ->
-      Tsig_cltype(newid, cltype_declaration s d)
+  | Tsig_class(id, d, rs) ->
+      Tsig_class(newid, class_declaration s d, rs)
+  | Tsig_cltype(id, d, rs) ->
+      Tsig_cltype(newid, cltype_declaration s d, rs)
 
 and modtype_declaration s = function
     Tmodtype_abstract -> Tmodtype_abstract
Index: typing/typemod.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/typemod.ml,v
retrieving revision 1.67
diff -u -r1.67 typemod.ml
--- typing/typemod.ml	9 Apr 2004 13:32:28 -0000	1.67
+++ typing/typemod.ml	17 May 2004 11:51:33 -0000
@@ -72,20 +72,21 @@
     match (sg, namelist, constr) with
       ([], _, _) ->
         raise(Error(loc, With_no_component lid))
-    | (Tsig_type(id, decl) :: rem, [s], Pwith_type sdecl)
+    | (Tsig_type(id, decl, rs) :: rem, [s], Pwith_type sdecl)
       when Ident.name id = s ->
         let newdecl = Typedecl.transl_with_constraint initial_env sdecl in
         Includemod.type_declarations env id newdecl decl;
-        Tsig_type(id, newdecl) :: rem
-    | (Tsig_module(id, mty) :: rem, [s], Pwith_module lid)
+        Tsig_type(id, newdecl, rs) :: rem
+    | (Tsig_module(id, mty, rs) :: rem, [s], Pwith_module lid)
       when Ident.name id = s ->
         let (path, mty') = type_module_path initial_env loc lid in
         let newmty = Mtype.strengthen env mty' path in
         ignore(Includemod.modtypes env newmty mty);
-        Tsig_module(id, newmty) :: rem
-    | (Tsig_module(id, mty) :: rem, s :: namelist, _) when Ident.name id = s ->
+        Tsig_module(id, newmty, rs) :: rem
+    | (Tsig_module(id, mty, rs) :: rem, s :: namelist, _)
+      when Ident.name id = s ->
         let newsg = merge env (extract_sig env loc mty) namelist in
-        Tsig_module(id, Tmty_signature newsg) :: rem
+        Tsig_module(id, Tmty_signature newsg, rs) :: rem
     | (item :: rem, _, _) ->
         item :: merge (Env.add_item item env) rem namelist in
   try
@@ -93,6 +94,14 @@
   with Includemod.Error explanation ->
     raise(Error(loc, With_mismatch(lid, explanation)))
 
+(* Add recursion flags on declarations arising from a mutually recursive
+   block. *)
+
+let map_rec fn decls rem =
+  match decls with
+  | [] -> rem
+  | d1 :: dl -> fn Trec_first d1 :: map_end (fn Trec_next) dl rem
+
 (* Auxiliary for translating recursively-defined module types.
    Return a module type that approximates the shape of the given module
    type AST.  Retain only module, type, and module type
@@ -128,11 +137,11 @@
         | Psig_type sdecls ->
             let decls = Typedecl.approx_type_decl env sdecls in
             let rem = approx_sig env srem in
-            map_end (fun (id, info) -> Tsig_type(id, info)) decls rem
+            map_rec (fun rs (id, info) -> Tsig_type(id, info, rs)) decls rem
         | Psig_module(name, smty) ->
             let mty = approx_mty env smty in
             let (id, newenv) = Env.enter_module name mty env in
-            Tsig_module(id, mty) :: approx_sig newenv srem
+            Tsig_module(id, mty, Trec_not) :: approx_sig newenv srem
         | Psig_recmodule sdecls ->
             let decls =
               List.map
@@ -142,7 +151,7 @@
             let newenv =
               List.fold_left (fun env (id, mty) -> Env.add_module id mty env)
               env decls in
-            map_end (fun (id, mty) -> Tsig_module(id, mty)) decls
+            map_rec (fun rs (id, mty) -> Tsig_module(id, mty, rs)) decls
                     (approx_sig newenv srem)
         | Psig_modtype(name, sinfo) ->
             let info = approx_mty_info env sinfo in
@@ -163,11 +172,12 @@
             let decls = Typeclass.approx_class_declarations env sdecls in
             let rem = approx_sig env srem in
             List.flatten
-              (List.map
-                (fun (i1, d1, i2, d2, i3, d3) ->
-                  [Tsig_cltype(i1, d1); Tsig_type(i2, d2); Tsig_type(i3, d3)])
-                decls)
-            @ rem
+              (map_rec
+                (fun rs (i1, d1, i2, d2, i3, d3) ->
+                  [Tsig_cltype(i1, d1, rs);
+                   Tsig_type(i2, d2, rs);
+                   Tsig_type(i3, d3, rs)])
+                decls [rem])
         | _ ->
             approx_sig env srem
 
@@ -204,9 +214,9 @@
   else set_ref := StringSet.add name !set_ref
 
 let check_sig_item type_names module_names modtype_names loc = function
-    Tsig_type(id, _) ->
+    Tsig_type(id, _, _) ->
       check "type" loc type_names (Ident.name id)
-  | Tsig_module(id, _) ->
+  | Tsig_module(id, _, _) ->
       check "module" loc module_names (Ident.name id)
   | Tsig_modtype(id, _) ->
       check "module type" loc modtype_names (Ident.name id)
@@ -261,7 +271,7 @@
               sdecls;
             let (decls, newenv) = Typedecl.transl_type_decl env sdecls in
             let rem = transl_sig newenv srem in
-            map_end (fun (id, info) -> Tsig_type(id, info)) decls rem
+            map_rec (fun rs (id, info) -> Tsig_type(id, info, rs)) decls rem
         | Psig_exception(name, sarg) ->
             let arg = Typedecl.transl_exception env sarg in
             let (id, newenv) = Env.enter_exception name arg env in
@@ -272,7 +282,7 @@
             let mty = transl_modtype env smty in
             let (id, newenv) = Env.enter_module name mty env in
             let rem = transl_sig newenv srem in
-            Tsig_module(id, mty) :: rem
+            Tsig_module(id, mty, Trec_not) :: rem
         | Psig_recmodule sdecls ->
             List.iter
               (fun (name, smty) ->
@@ -281,7 +291,7 @@
             let (decls, newenv) =
               transl_recmodule_modtypes item.psig_loc env sdecls in
             let rem = transl_sig newenv srem in
-            map_end (fun (id, mty) -> Tsig_module(id, mty)) decls rem
+            map_rec (fun rs (id, mty) -> Tsig_module(id, mty, rs)) decls rem
         | Psig_modtype(name, sinfo) ->
             check "module type" item.psig_loc modtype_names name;
             let info = transl_modtype_info env sinfo in
@@ -312,10 +322,12 @@
             let (classes, newenv) = Typeclass.class_descriptions env cl in
             let rem = transl_sig newenv srem in
             List.flatten
-              (map_end
-                 (fun (i, d, i', d', i'', d'', i''', d''', _, _, _) ->
-                    [Tsig_class(i, d);    Tsig_cltype(i', d');
-                     Tsig_type(i'', d''); Tsig_type(i''', d''')])
+              (map_rec
+                 (fun rs (i, d, i', d', i'', d'', i''', d''', _, _, _) ->
+                    [Tsig_class(i, d, rs);
+                     Tsig_cltype(i', d', rs);
+                     Tsig_type(i'', d'', rs);
+                     Tsig_type(i''', d''', rs)])
                  classes [rem])
         | Psig_class_type cl ->
             List.iter
@@ -325,10 +337,11 @@
             let (classes, newenv) = Typeclass.class_type_declarations env cl in
             let rem = transl_sig newenv srem in
             List.flatten
-              (map_end
-                 (fun (i, d, i', d', i'', d'') ->
-                    [Tsig_cltype(i, d);
-                     Tsig_type(i', d'); Tsig_type(i'', d'')])
+              (map_rec
+                 (fun rs (i, d, i', d', i'', d'') ->
+                    [Tsig_cltype(i, d, rs);
+                     Tsig_type(i', d', rs);
+                     Tsig_type(i'', d'', rs)])
                  classes [rem])
     in transl_sig env sg
 
@@ -379,7 +392,7 @@
 
 and closed_signature_item = function
     Tsig_value(id, desc) -> Ctype.closed_schema desc.val_type
-  | Tsig_module(id, mty) -> closed_modtype mty
+  | Tsig_module(id, mty, _) -> closed_modtype mty
   | _ -> true
 
 let check_nongen_scheme env = function
@@ -407,8 +420,8 @@
   | Tsig_value(id, {val_kind = Val_reg}) :: rem ->
       id :: bound_value_identifiers rem
   | Tsig_exception(id, decl) :: rem -> id :: bound_value_identifiers rem
-  | Tsig_module(id, mty) :: rem -> id :: bound_value_identifiers rem
-  | Tsig_class(id, decl) :: rem -> id :: bound_value_identifiers rem
+  | Tsig_module(id, mty, _) :: rem -> id :: bound_value_identifiers rem
+  | Tsig_class(id, decl, _) :: rem -> id :: bound_value_identifiers rem
   | _ :: rem -> bound_value_identifiers rem
 
 (* Helpers for typing recursive modules *)
@@ -540,7 +553,7 @@
           enrich_type_decls anchor decls env newenv in
         let (str_rem, sig_rem, final_env) = type_struct newenv' srem in
         (Tstr_type decls :: str_rem,
-         map_end (fun (id, info) -> Tsig_type(id, info)) decls sig_rem,
+         map_rec (fun rs (id, info) -> Tsig_type(id, info, rs)) decls sig_rem,
          final_env)
     | {pstr_desc = Pstr_exception(name, sarg)} :: srem ->
         let arg = Typedecl.transl_exception env sarg in
@@ -563,7 +576,7 @@
         let (id, newenv) = Env.enter_module name mty env in
         let (str_rem, sig_rem, final_env) = type_struct newenv srem in
         (Tstr_module(id, modl) :: str_rem,
-         Tsig_module(id, modl.mod_type) :: sig_rem,
+         Tsig_module(id, modl.mod_type, Trec_not) :: sig_rem,
          final_env)
     | {pstr_desc = Pstr_recmodule sbind; pstr_loc = loc} :: srem ->
         List.iter
@@ -591,7 +604,7 @@
         let bind = List.map2 type_recmodule_binding decls sbind in
         let (str_rem, sig_rem, final_env) = type_struct newenv srem in
         (Tstr_recmodule bind :: str_rem,
-         map_end (fun (id, modl) -> Tsig_module(id, modl.mod_type))
+         map_rec (fun rs (id, modl) -> Tsig_module(id, modl.mod_type, rs))
                  bind sig_rem,
          final_env)
     | {pstr_desc = Pstr_modtype(name, smty); pstr_loc = loc} :: srem ->
@@ -623,10 +636,12 @@
            (List.map (fun (_,_,_,_,_,_, i, d, _,_,_) -> (i, d)) classes) ::
          str_rem,
          List.flatten
-           (map_end
-              (fun (i, d, i', d', i'', d'', i''', d''', _, _, _) ->
-                 [Tsig_class(i, d);    Tsig_cltype(i', d');
-                  Tsig_type(i'', d''); Tsig_type(i''', d''')])
+           (map_rec
+              (fun rs (i, d, i', d', i'', d'', i''', d''', _, _, _) ->
+                 [Tsig_class(i, d, rs);
+                  Tsig_cltype(i', d', rs);
+                  Tsig_type(i'', d'', rs);
+                  Tsig_type(i''', d''', rs)])
               classes [sig_rem]),
          final_env)
     | {pstr_desc = Pstr_class_type cl; pstr_loc = loc} :: srem ->
@@ -643,9 +658,11 @@
            (List.map (fun (_, _, _, _, i, d) -> (i, d)) classes) ::
          str_rem,
          List.flatten
-           (map_end
-              (fun (i, d, i', d', i'', d'') ->
-                 [Tsig_cltype(i, d); Tsig_type(i', d'); Tsig_type(i'', d'')])
+           (map_rec
+              (fun rs (i, d, i', d', i'', d'') ->
+                 [Tsig_cltype(i, d, rs);
+                  Tsig_type(i', d', rs);
+                  Tsig_type(i'', d'', rs)])
               classes [sig_rem]),
          final_env)
     | {pstr_desc = Pstr_include smodl; pstr_loc = loc} :: srem ->
@@ -683,7 +700,7 @@
 
 and normalize_signature_item env = function
     Tsig_value(id, desc) -> Ctype.normalize_type env desc.val_type
-  | Tsig_module(id, mty) -> normalize_modtype env mty
+  | Tsig_module(id, mty, _) -> normalize_modtype env mty
   | _ -> ()
 
 (* Simplify multiple specifications of a value or an exception in a signature.
@@ -710,9 +727,9 @@
       simplif val_names (StringSet.add name exn_names)
               (if StringSet.mem name exn_names then res else component :: res)
               sg
-  | Tsig_module(id, mty) :: sg ->
+  | Tsig_module(id, mty, rs) :: sg ->
       simplif val_names exn_names
-              (Tsig_module(id, simplify_modtype mty) :: res) sg
+              (Tsig_module(id, simplify_modtype mty, rs) :: res) sg
   | component :: sg ->
       simplif val_names exn_names (component :: res) sg
   in
@@ -757,7 +774,7 @@
       let sg' = Subst.signature subst sg in
       let oldid = Ident.create_persistent name
       and newid = Ident.create name in
-      Tsig_module(newid, Tmty_signature sg') ::
+      Tsig_module(newid, Tmty_signature sg', Trec_not) ::
       package_signatures (Subst.add_module oldid (Pident newid) subst) rem
 
 let package_units objfiles cmifile modulename =
Index: typing/types.ml
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/types.ml,v
retrieving revision 1.22
diff -u -r1.22 types.ml
--- typing/types.ml	25 Nov 2003 09:20:43 -0000	1.22
+++ typing/types.ml	17 May 2004 09:48:27 -0000
@@ -181,13 +181,18 @@
 
 and signature_item =
     Tsig_value of Ident.t * value_description
-  | Tsig_type of Ident.t * type_declaration
+  | Tsig_type of Ident.t * type_declaration * rec_status
   | Tsig_exception of Ident.t * exception_declaration
-  | Tsig_module of Ident.t * module_type
+  | Tsig_module of Ident.t * module_type * rec_status
   | Tsig_modtype of Ident.t * modtype_declaration
-  | Tsig_class of Ident.t * class_declaration
-  | Tsig_cltype of Ident.t * cltype_declaration
+  | Tsig_class of Ident.t * class_declaration * rec_status
+  | Tsig_cltype of Ident.t * cltype_declaration * rec_status
 
 and modtype_declaration =
     Tmodtype_abstract
   | Tmodtype_manifest of module_type
+
+and rec_status =
+    Trec_not
+  | Trec_first
+  | Trec_next
Index: typing/types.mli
===================================================================
RCS file: /net/pauillac/caml/repository/csl/typing/types.mli,v
retrieving revision 1.22
diff -u -r1.22 types.mli
--- typing/types.mli	25 Nov 2003 09:20:43 -0000	1.22
+++ typing/types.mli	17 May 2004 09:06:08 -0000
@@ -183,13 +183,18 @@
 
 and signature_item =
     Tsig_value of Ident.t * value_description
-  | Tsig_type of Ident.t * type_declaration
+  | Tsig_type of Ident.t * type_declaration * rec_status
   | Tsig_exception of Ident.t * exception_declaration
-  | Tsig_module of Ident.t * module_type
+  | Tsig_module of Ident.t * module_type * rec_status
   | Tsig_modtype of Ident.t * modtype_declaration
-  | Tsig_class of Ident.t * class_declaration
-  | Tsig_cltype of Ident.t * cltype_declaration
+  | Tsig_class of Ident.t * class_declaration * rec_status
+  | Tsig_cltype of Ident.t * cltype_declaration * rec_status
 
 and modtype_declaration =
     Tmodtype_abstract
   | Tmodtype_manifest of module_type
+
+and rec_status =
+    Trec_not                            (* not recursive *)
+  | Trec_first                          (* first in a recursive group *)
+  | Trec_next                           (* not first in a recursive group *)
Index: utils/config.mlp
===================================================================
RCS file: /net/pauillac/caml/repository/csl/utils/config.mlp,v
retrieving revision 1.194
diff -u -r1.194 config.mlp
--- utils/config.mlp	3 Jul 2003 15:13:23 -0000	1.194
+++ utils/config.mlp	17 May 2004 09:05:07 -0000
@@ -40,7 +40,7 @@
 let cc_profile = "%%CC_PROFILE%%"
 
 let exec_magic_number = "Caml1999X007"
-and cmi_magic_number = "Caml1999I009"
+and cmi_magic_number = "Caml1999I010"
 and cmo_magic_number = "Caml1999O005"
 and cma_magic_number = "Caml1999A006"
 and cmx_magic_number = "Caml1999Y008"

