With the improvements to the module system in ocaml 3.12 extending a
signature just got much much lighter. Suppose I want the signature of
the module which in every respects is like StdLabels excepted that the
String module has an extra "is_prefix_of" I can write:

  module String : sig
    include module type of StdLabels.String
    val is_prefix_of : string ->  string ->  bool
  end

  include module type of StdLabels with module String :=  String

I know of no way to extend the implementation in a similarly concise
way (for which the length of the solution does not depend on the
number of top level items in StdLabels). Have I overlooked anything
obvious?

Till

P.S.: FYI existing solution for the implementation:

  module String = struct
    include StringLabels

    let is_prefix_of (needle:string) (haystack:string) : bool =
      let len = length needle in
      len <= length haystack && (sub haystack ~pos:0 ~len = needle)
  end

  (* Haven't quite found out how to include a module hiding another one... *)
  module List = ListLabels
  module Array = ArrayLabels

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to