<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2003/01/b4e7497511793e9b3526abc8b6da6d2d"
  from="Thorsten Ohl &lt;ohl@p...&gt;"
  author="Thorsten Ohl"
  date="2003-01-14T21:06:43"
  subject="[Caml-list] Legality of using module types from .mli in .ml"
  prev="2003/01/d0f4e551ba89f8f7b4b9cfad3f89e3df"
  next="2003/01/a2655a29f853a3b70108ffd4274e4fa2"
  next-in-thread="2003/01/c93ae47484a0ce585b8050618e59f3d0"
  prev-thread="2003/01/6b3b8aa926b31df45c1942e68097615c"
  next-thread="2003/01/a2655a29f853a3b70108ffd4274e4fa2"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Legality of using module types from .mli in .ml">
<msg 
  url="2003/01/b4e7497511793e9b3526abc8b6da6d2d"
  from="Thorsten Ohl &lt;ohl@p...&gt;"
  author="Thorsten Ohl"
  date="2003-01-14T21:06:43"
  subject="[Caml-list] Legality of using module types from .mli in .ml">
<msg 
  url="2003/01/c93ae47484a0ce585b8050618e59f3d0"
  from="Julien Signoles &lt;Julien.Signoles@l...&gt;"
  author="Julien Signoles"
  date="2003-01-15T16:33:59"
  subject="[Caml-list] Re: Legality of using module types from .mli in .ml">
<msg 
  url="2003/01/d68f500a1b2410c0abf79fecd45781d3"
  from="Thorsten Ohl &lt;ohl@p...&gt;"
  author="Thorsten Ohl"
  date="2003-01-15T17:50:43"
  subject="[Caml-list] Re: Legality of using module types from .mli in .ml">
<msg 
  url="2003/01/7b4356fccebf28ce028122d7511e4854"
  from="Julien Signoles &lt;Julien.Signoles@l...&gt;"
  author="Julien Signoles"
  date="2003-01-15T17:48:55"
  subject="[Caml-list] Re: Legality of using module types from .mli in .ml">
<msg 
  url="2003/01/5ca757063c7fae3284cbb1919186faa3"
  from="David Brown &lt;caml-list@d...&gt;"
  author="David Brown"
  date="2003-01-15T21:58:04"
  subject="Re: [Caml-list] Re: Legality of using module types from .mli in .ml">
</msg>
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>
I'm often referring to module types defined in an interface file in
order to reduce redundancy.  For example

    $ cat a.mli
    module type T = sig val n : int end
    module M : T

    $ cat a.ml
    module type T = A.T
    module M : T = struct let n = 42 end

where T can be rather long.  Is this legal?  The manual says in
section 6.12

    A compilation unit behaves roughly as the module definition
    module unit-name : sig  unit-interface end =  struct unit-implementation end 

and refrains from defining `roughly' :-).  I came up with conflicting
evidence:

O'Caml accepts it
    
    $ ocamlopt a.mli a.ml 

However, it is not equivalent to

    module B :
      sig
	module type T = sig val n : int end
      end =
      struct
	module type T = B.T
	module M = struct let n = 42 end
      end
    
which is obviously rejected by O'Caml, since B.T is not bound.  The
pair (a.mli, a.ml) more closely resembles

    module Aux_C =
      struct
	module type T = sig val n : int end
      end
    
    module type C =
      sig
	module type T = Aux_C.T
	module M : T
      end
    
    module C : C =
      struct
	module type T = Aux_C.T
	module M = struct let n = 42 end
      end

without binding Aux.T.  My question is now: is the pair (a.mli, a.ml)
intentionally legal or do I need to expand the reference A.T, as in

    $ cat pedantic_a.mli
    module type T = sig val n : int end
    module M : T

    $ cat pedantic_a.ml
    module type T = sig val n : int end
    module M : T = struct let n = 42 end

because I've have taken advantage of a bug in the compiler.

The reason I'm asking this, is that my shorthand [as in (a.mli, aml)]
breaks Julien Signoles' defunctorizer.

Cheers,
-Thorsten
-- 
Thorsten Ohl, Physics Dept., Wuerzburg Univ. -- ohl@physik.uni-wuerzburg.de
http://theorie.physik.uni-wuerzburg.de/~ohl/     [&lt;=== PGP public key here]
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

