| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| I have two ml files: a.ml and b.ml. In a.ml, I have: module type Spec = sig type t val transform : t -> float end module Make (Spec : Spec) = struct let start mystream = Stream.map (IData.app Spec.transform) mystream end In b.ml, I have: module MySpec : A.Spec = struct type t = string let transform x = float_of_string x end module B = A.Make(MySpec);; B.start f;; (* this is where the error occurs *) Stream and IData are two modules defined in two other seperate files: stream.ml and iData.ml. Stream has function map which is similar to List.map and IData has function app that applies a function to a value. f has type string IData Stream. My a.ml could compile fine. Compiling b.ml with a.cmi gives the following error: This expression (f) has type string IData.t Stream.t but is here used with type MySpec.t IData.t Stream.t The type constructor MySpec.t would escape its scope What is really wrong here? I suspect it is because of the two separate files stream.ml and iData.ml that I have... Thanks! |
|
#2
| |||
| |||
| On Apr 14, 11:05*pm, kenzhu2...@gmail.com wrote: > > This expression (f) has type string IData.t Stream.t > but is here used with type MySpec.t IData.t Stream.t > The type constructor MySpec.t would escape its scope Because of the signature ascription " : A.Spec", the module MySpec is sealed and the type MySpec.t made abstract. Try either removing the ascription, or make t transparent by refining it to " : A.Spec with type t = string". - Andreas |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.