* Probleme d'interface
@ 1996-06-13 16:45 Bouzid Djamila
1996-06-14 10:21 ` Wolfgang Lux
0 siblings, 1 reply; 4+ messages in thread
From: Bouzid Djamila @ 1996-06-13 16:45 UTC (permalink / raw)
To: caml-list
Bonjour,
Voila, j'ai deux fichiers CSL (Caml Special Light)
vendor.mli (pour l'interface) et vendor.ml
(* fichier 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 *)
(* fichier 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 *)
A la compilation, voila le message d'erreur que je recois a chaque fois
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 %
J'ai essaye toutes les methodes, mais a chaque fois je tombe sur
la meme erreur.
Pouvez_vous ,s'il vous plait, m'expliquer a quoi est du ce probleme ?
Merci de votre reponse
-----------------------------------------------------------------------------
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 ?
Thanks for the response.
D. Bouzid.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Probleme d'interface
1996-06-13 16:45 Probleme d'interface Bouzid Djamila
@ 1996-06-14 10:21 ` Wolfgang Lux
1996-06-14 15:45 ` Bouzid Djamila
0 siblings, 1 reply; 4+ messages in thread
From: Wolfgang Lux @ 1996-06-14 10:21 UTC (permalink / raw)
To: Bouzid Djamila; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Probleme d'interface
1996-06-14 10:21 ` Wolfgang Lux
@ 1996-06-14 15:45 ` Bouzid Djamila
1996-06-17 9:06 ` Wolfgang Lux
0 siblings, 1 reply; 4+ messages in thread
From: Bouzid Djamila @ 1996-06-14 15:45 UTC (permalink / raw)
To: Wolfgang Lux; +Cc: caml-list
Hi!
Thanks for all responses that I have received.
> The problem simply is, that you have to define both modules types
> VENDOR_INTEGER and VENDOR in vendor.ml as well to compile.
So I have mixed vendor.mli and vendor.ml in a single file vendor.ml.
(* vendor.ml *)
module type VENDOR_INTEGER =
sig
val min : int * int -> int
end (* sig *)
module type VENDOR =
sig
val print: string -> unit
(* Flush the standard out. *)
module Integer : VENDOR_INTEGER
end (* sig *)
module type TIMINGBOARD = sig end
module V (TimingBoard: TIMINGBOARD) : VENDOR =
struct
let print = print_string
module Integer : VENDOR_INTEGER =
struct
let min(x,y) = if x < y then x else y
end
end (* functor V *)
(*end of vendor.ml)
So the compilation is
finot ip 61 % cslc vendor.ml
I/O error: vendor.cmi: No such file or directory
finot ip 62 %
What means this error, if vendor.cmi is generated in compilation.
> 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!)
I have'nt inderstood why module V is not visible at all outside in this
case of vendor.ml. ^^^
>
> If you look into the Caml Special Light reference,
please, could you tell me where can I find this reference ?
I have only Caml Special Light reference manual, I want to have
more references of this language.
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
>
But if we want have
module V : VENDOR =
.......
end (*V*)
module V1 = V
module V2 = V
or
module V (....) : VENDOR =
struct
......
end (*functor*)
What should I do ?
>
> Hope this helps,
Thanks a lot.
D. Bouzid.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Probleme d'interface
1996-06-14 15:45 ` Bouzid Djamila
@ 1996-06-17 9:06 ` Wolfgang Lux
0 siblings, 0 replies; 4+ messages in thread
From: Wolfgang Lux @ 1996-06-17 9:06 UTC (permalink / raw)
To: Bouzid Djamila; +Cc: caml-list
Bouzid Djamila <Bouzid.Djamila@loria.fr> writes:
> So I have mixed vendor.mli and vendor.ml in a single file vendor.ml.
>
[ vendor.ml omitted ]
>
> So the compilation is
>
> finot ip 61 % cslc vendor.ml
> I/O error: vendor.cmi: No such file or directory
> finot ip 62 %
>
> What means this error, if vendor.cmi is generated in compilation.
I guess you haven't deleted or moved away vendor.mli. Before
generating vendor.cmi from vendor.ml, the compiler first looks for a
file vendor.mli in the same directory as vendor.ml and if one is found
it assumes, that the interface file vendor.mli should be compiled
first to generate vendor.cmi. Only if that file doesn't exist, it will
generate a default interface from vendor.ml.
>
> I have'nt inderstood why module V is not visible at all outside in this
> case of vendor.ml. ^^^
>
Just because all exported entities (types, values, modules and module
types) must also be declared in the interface specification, aka
signature of the module. Your interface did only export the module
types VENDOR and VENDOR_INTEGER, but not the module V. So it isn't
visible outside of vendor.
> >
> > If you look into the Caml Special Light reference,
>
> please, could you tell me where can I find this reference ?
> I have only Caml Special Light reference manual, I want to have
> more references of this language.
Sorry, I meant the reference manual.
[ ... ]
>
> But if we want have
>
> module V : VENDOR =
> .......
> end (*V*)
>
> module V1 = V
> module V2 = V
>
> or
>
> module V (....) : VENDOR =
> struct
> ......
> end (*functor*)
>
> What should I do ?
>
You can simply add the following declaration to your interface file
vendor.mli:
module V : VENDOR
or
module V (TimingBoard: TIMINGBOARD) : VENDOR
So the file vendor.mli, from your original posting should read:
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 *)
module V : VENDOR
Regards
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
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1996-06-17 17:31 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-13 16:45 Probleme d'interface Bouzid Djamila
1996-06-14 10:21 ` Wolfgang Lux
1996-06-14 15:45 ` Bouzid Djamila
1996-06-17 9:06 ` Wolfgang Lux
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox