Commits

Anonymous committed 216eb4d

functor arg mty

Comments (0)

Files changed (3)

ocamlspot/ocamlspot.ml

         | Mod_ident p -> Format.fprintf ppf "%s" (Path.name p)
         | Mod_packed s -> Format.fprintf ppf "packed(%s)" s
         | Mod_structure str -> structure (* ? format_structure *) ppf str
-        | Mod_functor (id, mexp) ->
-            Format.fprintf ppf "\\%s -> %a" 
+        | Mod_functor (id, mty, mexp) ->
+            Format.fprintf ppf "\\(%s:@[%a@]) -> %a" 
               (Ident.name id)
+              Printtyp.modtype mty
               module_expr (* ? format_module_expr *) mexp
         | Mod_apply (mexp1, mexp2) ->
             Format.fprintf ppf "%a(%a)"
       | Ident of PIdent.t (* ? PIdent.t *)
       | Structure of PIdent.t * structure
       | Parameter of PIdent.t
-      | Closure of PIdent.t * env * Ident.t * Abstraction.module_expr
+      | Closure of PIdent.t * env * Ident.t * Types.module_type * Abstraction.module_expr
       | Error of exn 
     (* <= Value.t *)
 
       let cache = ref []
       let rec t = function
         | Structure (_, str) -> structure str
-        | Closure (_, e, _, _) -> env e
+        | Closure (_, e, _, _, _) -> env e
         | Ident _ | Parameter _ | Error _ -> ()
       and env e = binding e.binding
       and binding b =
 	    Format.fprintf ppf "@[<v2>Module(%a)@ %a@]"
 	      PIdent.format pid
               structure str
-        | Closure (pid, _, id, module_expr) ->
+        | Closure (pid, _, id, _mty, module_expr) ->
 	    Format.fprintf ppf "(@[<2>(%a =)fun %s ->@ @[%a@]@])" 
 	      PIdent.format pid
 	      (Ident.name id)
             Structure ({ PIdent.path= env.path;
 			 ident = idopt }, str)
           end
-      | Mod_functor (id, mexp) -> 
-(*
-	  Format.eprintf "evaluating functor (arg %s) under %s@."
+      | Mod_functor (id, mty, mexp) -> 
+	  Debug.format "evaluating functor (arg %s) under %s@."
 	    (Ident.name id)
-	    (String.concat "; " (List.map (fun (id, _) -> Ident.name id) env.Env.structure));
-*)
-	  eager (Closure ({ PIdent.path = env.path;
-			    ident = idopt }, env, id, mexp))
+	    (String.concat "; " (List.map Ident.name (Env.domain env)));
+	  eager (Closure ({ PIdent.path = env.path; ident = idopt }, 
+                         env, id, mty, mexp))
       | Mod_constraint (mexp, _mty) -> 
           (* [_mty] may not be a simple signature but an ident which is
              hard to get its definition at this point. 
 	  | Structure _ -> assert false
           | Parameter _ -> Error (Failure "parameterized")
           | Error exn -> Error exn
-	  | Closure (_, env, id, mexp) -> 
+	  | Closure (_, env, id, _mty, mexp) -> 
               !!(module_expr (Env.override env (id, (Kind.Module, v2)))
                     None(*?*) mexp)
           end
         | Value.Ident id -> id, find_loc id
         | Value.Structure (id, _)  -> id, find_loc id
         | Value.Parameter _ -> Format.eprintf "it is in a parameter@."; assert false
-        | Value.Closure (id, _, _, _) -> id, find_loc id
+        | Value.Closure (id, _, _, _, _) -> id, find_loc id
         | Value.Error (Failure s) -> Format.eprintf "Error %s@." s; assert false
         | Value.Error exn -> Format.eprintf "Error %s@." (Printexc.to_string exn); assert false
       in
     | Mod_packed of string (* full path *)
         (* -pack overrides load paths: ocamlc -pack dir1/dir2/dir3/x.cmo *)
     | Mod_structure of structure (* module M = struct ... end *)
-    | Mod_functor of Ident.t * module_expr (* module M(I:...) = *)
+    | Mod_functor of Ident.t * Types.module_type * module_expr (* module M(I:S) = *)
     | Mod_apply of module_expr * module_expr (* module M = N(O) *)
     | Mod_constraint of module_expr * Types.module_type
 
 	  (List.fold_right (fun stritem st ->
 	    structure_item stritem @ st)
 	     str [])
-    | Tmod_functor (id, _mty, mexp) ->
-	Mod_functor(id, module_expr mexp)
+    | Tmod_functor (id, mty, mexp) ->
+	Mod_functor(id, mty, module_expr mexp)
     | Tmod_apply (mexp1, mexp2, _mcoercion) -> (* CR jfuruse ? *)
 	Mod_apply (module_expr mexp1, module_expr mexp2)
     | Tmod_constraint (mexp, mty, _mcoercion) ->
     | Mod_packed of string (* full path *)
         (* -pack overrides load paths: ocamlc -pack dir1/dir2/dir3/x.cmo *)
     | Mod_structure of structure (* module M = struct ... end *)
-    | Mod_functor of Ident.t * module_expr (* module M(I:...) = *)
+    | Mod_functor of Ident.t * Types.module_type * module_expr (* module M(I:S) = *)
     | Mod_apply of module_expr * module_expr (* module M = N(O) *)
     | Mod_constraint of module_expr * Types.module_type