Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Wolfgang Lux <lux@heidelbg.ibm.com>
To: Bouzid Djamila <Bouzid.Djamila@loria.fr>
Cc: caml-list@pauillac.inria.fr
Subject: Re: Probleme d'interface
Date: Fri, 14 Jun 96 11:21:04 +0100	[thread overview]
Message-ID: <9606140921.AA32629@idse.heidelbg.ibm.com> (raw)
In-Reply-To: (Your message of Thu, 13 Jun 96 18:45:33 O.) <199606131645.SAA17944@delsarte.loria.fr>


Bouzid Djamila <Bouzid.Djamila@loria.fr> writes:
> 
> Hi!
> 
> I have two CSL files : vendor.mli (the interface) and vendor.ml
> 
> (* vendor.mli *)
> module type VENDOR_INTEGER = 
>  sig
>   val min : int * int -> int
>  end (* sig *)
> 
> module type VENDOR =
>  sig
>   val print: string -> unit
>   module Integer : VENDOR_INTEGER
>  end (* sig *)
> 
> 
> (*vendor.ml *)
> open vendor
>  module  V : VENDOR =
>   struct
>    let print = print_string
>    module Integer : VENDOR_INTEGER =
>     struct
>       let min ((x:int),(y:int)) = if x < y then x else y
>     end
>   end  (* functor V *)
> 
> when compiling these programs, I receive the following error message :
> 
> finot ip 175 % cslc -i vendor.mli
> module type VENDOR_INTEGER = sig val min : int * int -> int end
> module type VENDOR =
>   sig val print : string -> unit module Integer : VENDOR_INTEGER end
> finot ip 176 % cslc -i vendor.ml
> module V : Vendor.VENDOR
> The implementation vendor.ml does not match the interface vendor.cmi:
> The field `VENDOR' is required but not provided
> The field `VENDOR_INTEGER' is required but not provided
> finot ip 177 % 
> 
> Please, could you tell me where's the problem ?
> 
The problem simply is, that you have to define both modules types
VENDOR_INTEGER and VENDOR in vendor.ml as well to compile.

But actually this is not what you really want, as the local module V
is not visible at all outside of vendor.ml! (And in contrary to your
comment it is not a functor!)

If you look into the Caml Special Light reference, you will see that
the files vendor.mli and vendor.ml constitute themselves a module
which is roughly equivalent to

  module Vendor :
    sig
      <<contents of vendor.mli>>
    end =
    struct
      <<contents of vendor.ml>>
    end

So you wanted probably to write the following module interface vendor.mli:

    module type VENDOR_INTEGER = 
      sig
	val min : int * int -> int
      end (* sig *)

    val print: string -> unit
    module Integer : VENDOR_INTEGER

And your implementation vendor.ml then would look as follows:

    module type VENDOR_INTEGER = 
      sig
	val min : int * int -> int
      end

    let print = print_string
    module Integer : VENDOR_INTEGER =
      struct
        let min ((x:int),(y:int)) = if x < y then x else y
      end


Hope this helps,
Wolfgang

----
Wolfgang Lux
WZH Heidelberg, IBM Germany             Internet: lux@heidelbg.ibm.com
+49-6221-59-4546                        VNET:     LUX at HEIDELBG
+49-6221-59-3500 (fax)	                EARN:     LUX at DHDIBMIP





  reply	other threads:[~1996-06-14 17:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-06-13 16:45 Bouzid Djamila
1996-06-14 10:21 ` Wolfgang Lux [this message]
1996-06-14 15:45   ` Bouzid Djamila
1996-06-17  9:06     ` Wolfgang Lux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9606140921.AA32629@idse.heidelbg.ibm.com \
    --to=lux@heidelbg.ibm.com \
    --cc=Bouzid.Djamila@loria.fr \
    --cc=caml-list@pauillac.inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox