Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0005460OCamlOCaml generalpublic2012-01-03 04:472012-03-07 08:26
Reporterhcarty 
Assigned Togarrigue 
PrioritynormalSeverityfeatureReproducibilityalways
StatusassignedResolutionopen 
PlatformOSOS Version
Product Version3.12.1 
Target VersionFixed in Version 
Summary0005460: Request: Replace/rename/remove module types
DescriptionAs of the 3.12.x releases, we can replace types (... with type t := t') and remove modules (... with module M := M) in module signatures. It would be useful to be able to do the same thing with module types.
Steps To Reproduce(* This works - module H will not have a Make module in it *)
module H = struct
  include (Hashtbl : module type of Hashtbl with module type S := Hashtbl.S)
end

(* In the toplevel (both 3.12.1 and 3.13.0+dev8) this fails with:
   "Syntax error: ')' expected, the highlighted '(' might be unmatched"
   on "type" in "... with module type S ..." *)
module type S' = sig type t end
module H = struct
  include (Hashtbl : module type of Hashtbl with module type S := S')
end
Additional InformationThis would be useful when extending modules, particularly ones which provide functors and matching signatures.
TagsNo tags attached.
Attached Fileslog file icon ocamlbrew.wrMNQO.log [^] (181,292 bytes) 2012-01-13 22:36

- Relationships
related to 0005514acknowledged "with module" semantics seem broken 

-  Notes
(0006586)
garrigue (manager)
2012-01-04 07:51

I'm not sure I understand the intended semantics.
The constructs with type t := ... and with module M := ... just replace t and M by the corresponding definitions, but you seem to imply that "with module type S := ..." should also remove modules and functors containing S in their signature.
I don't think this new approach would make sense: since module types are purely structural, there is no way to distinguish S from its definition.

Concerning the possibility to substitute a module type, I see no reason it wouldn't be possible.
Note however that this is actually two new constructs:
  with module type S = ...
  with module type S := ...
I don't see why we should have the second without the first.
(0006591)
hcarty (reporter)
2012-01-04 15:15

I would be quite happy with those two new "with module type" constructs. I don't see any reason why only one or the other should be added.

For some clarification on the original request - "with type t := t'" does replace t with t', but "with module M := M" (where both M modules are the same) removes that module from the signature:

module H = struct
  include (Hashtbl : module type of Hashtbl with module Make := Hashtbl.Make)
end

I apologize - looking back at the original post, this is the code I meant to include as the first example. The H module will now be just like Hashtbl, except that there is no H.Make module included.

I don't know if removal makes sense for a module type any more than it does for a normal type. There may be situations where it is useful, but being able to substitute a module type seems more useful.
(0006635)
garrigue (manager)
2012-01-10 05:24

I implemented the above features experimentally in trunk/experimental/garrigue/with-module-type.diffs
The two syntaxes are available (= and :=), and the right hand side may be any module type.

Your example goes through modulo an instantiation of "statistics":

module H = struct
  include (Hashtbl : module type of Hashtbl with
           type statistics = Hashtbl.statistics
           and module type S := Hashtbl.S)
end

Could you try it and verify that it does what you expect?
(0006639)
hcarty (reporter)
2012-01-10 15:09

I tried to build trunk with this patch applied but I received an error. I can attach the entire build log if that would be helpful.

cd tools; make all
make[2]: Entering directory `/home/hcarty/ocamlbrew/mod-diff/build/build/tools'
../boot/ocamlrun ../boot/ocamlc -strict-sequence -nostdlib -I ../boot -c -warn-error A -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp -I ../driver depend.mli
../boot/ocamlrun ../boot/ocamlc -strict-sequence -nostdlib -I ../boot -c -warn-error A -I ../utils -I ../parsing -I ../typing -I ../bytecomp -I ../asmcomp -I ../driver depend.ml
File "depend.ml", line 181, characters 8-261:
Warning 8: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
(_, (Pwith_modtype _|Pwith_modtypesubst _))
File "depend.ml", line 1:
Error: Error-enabled warnings (1 occurrences)
make[2]: *** [depend.cmo] Error 2
make[2]: Leaving directory `/home/hcarty/ocamlbrew/mod-diff/build/build/tools'
make[1]: *** [ocamltools] Error 2
make[1]: Leaving directory `/home/hcarty/ocamlbrew/mod-diff/build/build'
make: *** [world.opt] Error 2

- Issue History
Date Modified Username Field Change
2012-01-03 04:47 hcarty New Issue
2012-01-04 07:39 garrigue Assigned To => garrigue
2012-01-04 07:39 garrigue Status new => assigned
2012-01-04 07:51 garrigue Note Added: 0006586
2012-01-04 07:51 garrigue Status assigned => feedback
2012-01-04 15:15 hcarty Note Added: 0006591
2012-01-04 15:15 hcarty Status feedback => assigned
2012-01-10 05:24 garrigue Note Added: 0006635
2012-01-10 05:24 garrigue Status assigned => feedback
2012-01-10 15:09 hcarty Note Added: 0006639
2012-01-10 15:09 hcarty Status feedback => assigned
2012-01-13 22:36 hcarty File Added: ocamlbrew.wrMNQO.log
2012-03-07 08:26 garrigue Relationship added related to 0005514


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker