type constructor XXX would escape its scope

This is a discussion on type constructor XXX would escape its scope within the ml forums in Programming Languages category; 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 ...

Go Back   Application Development Forum > Programming Languages > ml

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 04-14-2008, 05:05 PM
kenzhu2000@gmail.com
Guest
 
Default type constructor XXX would escape its scope

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!


Reply With Quote
  #2  
Old 04-16-2008, 07:31 AM
rossberg@ps.uni-sb.de
Guest
 
Default Re: type constructor XXX would escape its scope

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


Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 02:09 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.