Le Thu, 8 Sep 2011 16:42:39 +0200 (CEST),
Walter Cazzola <[email protected]> a écrit :

> On Thu, 8 Sep 2011, Esther Baruk wrote:
> 
> > You must also put the signature of the module type CharPQueueAbs in
> > the implementation (A.ml).
> 
> this means that can't I separate signature from the implementation?
> That is do I have to keep both struct and sig in the same file? or do
> you mean something different.
> 
> Thanks for the hints
> 
> Walter

You seem to have misunderstood the system of modules, I send you your
files with variants which are compilable.
Never forgot that any object declared in an interface must be
implemented (it wasn't the case in your files, since CharPQueueAbst
was declared in the mli file, but not implemented in your ml file;
note also the difference between "implemented" and "instanciated").
========================================================
Implementation                 Interface
========================================================
module type X =                module type X =
 sig                            sig
  type t                         type t
  val habitant : t               val habitant : t
 end                            end

module Habited =               module Habited : X
 struct
  type t = bool
  let habitant = true
  let some_other = false
 end

module Habited2 =              module Habited2 :
 struct                         sig
  type t = bool                  type t
  let habitant = true            val habitant : t
  let some_other = false         val some_other : t
 end                            end

module Habited3 =              module Habited3 :
 struct                         sig
  type t = bool                  type t = bool
  let habitant = true            val habitant : bool
  let some_other = false         val some_other : t
 end                            end
========================================================
You can generate an interface with the "-i" option.
Note that interface of 'X' is itself;
and the same module may have many possible interfaces

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Attachment: archive.tgz
Description: application/compressed-tar

Reply via email to