Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Problem binding type parameters in modules
@ 1999-01-16 12:21 Markus Mottl
  1999-01-18 14:59 ` Sylvain BOULM'E
  1999-01-19  8:50 ` Problem binding type parameters in modules Hendrik Tews
  0 siblings, 2 replies; 6+ messages in thread
From: Markus Mottl @ 1999-01-16 12:21 UTC (permalink / raw)
  To: OCAML

Hello,

sometimes one has the impression that there must be a simple solution,
but one can just not see it...

My problem (example code):

---------------------------------------------------------------------------
module type FOO1 =
sig
  type 'a foo
  val empty : 'a foo
end

module type FOO2 =
sig
  type foo
  val empty : foo
end

(* ok *)
module Foo1 : FOO1 =
struct
  type 'a foo = 'a list
  let empty = []
end

(* also ok *)
module Foo2 : FOO2 =
struct
  type foo  = int list Lazy.t
  let empty = lazy []
end

(* not ok *)
module Bar : FOO1 =
struct
  type 'a foo = 'a list Lazy.t
  let empty = lazy []
end
---------------------------------------------------------------------------

The compiler will report an error, because it does not infer the type of
"empty" in module "Bar" as specified in "FOO1".

No matter what I have tried, I haven't succeed in binding the type
parameter needed in "empty" to "'a" in type "foo", so that the module
signatures would match. E.g.:

---------------------------------------------------------------------------
(* also not ok *)
module Bar : FOO1 =
struct
  type 'a foo = 'a list Lazy.t
  let empty : 'a foo = lazy []
end
---------------------------------------------------------------------------

The "'a" specified in "empty" is still not the same as in "'a foo". I have
not yet tried to use a functor to bind the function to the correct type,
but I think this should not be necessary. As one can see in the example,
the type of "empty" is correctly inferred in "Foo1" and "Foo2". I do
not understand, why the compiler does not do so in the last case.

Am I overlooking any easy way out? Or is this even a bug?

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-01-19 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-01-16 12:21 Problem binding type parameters in modules Markus Mottl
1999-01-18 14:59 ` Sylvain BOULM'E
1999-01-18 17:07   ` Problem binding type parameters in modules + subtyping and inheritance Markus Mottl
1999-01-18 19:16     ` Jerome Vouillon
1999-01-18 20:37       ` Markus Mottl
1999-01-19  8:50 ` Problem binding type parameters in modules Hendrik Tews

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox