Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

type constructor XXX would escape its scope

303 views
Skip to first unread message

kenzh...@gmail.com

unread,
Apr 14, 2008, 5:05:30 PM4/14/08
to comp-l...@moderators.isc.org
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!


ross...@ps.uni-sb.de

unread,
Apr 16, 2008, 7:31:01 AM4/16/08
to comp-l...@moderators.isc.org
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


0 new messages