caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] A confusing example with modules and polymorphic variants
@ 2012-10-19 21:18 Yaron Minsky
  2012-10-19 22:10 ` Jeremy Yallop
  0 siblings, 1 reply; 5+ messages in thread
From: Yaron Minsky @ 2012-10-19 21:18 UTC (permalink / raw)
  To: caml-list; +Cc: Stephen Weeks, David Powers, Nathan Linger

Sorry for the previous incomplete message.  Over-eager return key.

We've been running into some troubles with polymorphic variants,
modules, and the value restriction, that we're not quite able to
unravel.  Here's a stripped down version of the problem.

    module type S = sig
      val z : [< `Foo ]
    end

    let f z =
      let module M : S = struct let z = z end in ()

Roughly speaking, we have a module signature S with a value that's a
polymorphic variant type that is not exact (i.e., has some
polymorphism in it.)

The function f then tries to construct a module of that type, by
taking the input value and stuffing it into a locally defined module.
When we do this, however, we're hit by a non-generalizable value
complaint.

    Modules do not match: sig val z : '_a end is not included in S
    Values do not match: val z : '_a is not included in val z : [< `Foo ]
    File "z.ml", line 2, characters 2-19: Expected declaration
    File "z.ml", line 7, characters 8-9: Actual declaration

Any thoughts on why this doesn't work, and how one could get it to?

^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Caml-list] A confusing example with modules and polymorphic variants
@ 2012-10-19 21:13 Yaron Minsky
  0 siblings, 0 replies; 5+ messages in thread
From: Yaron Minsky @ 2012-10-19 21:13 UTC (permalink / raw)
  To: caml-list



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

end of thread, other threads:[~2012-10-20  9:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-19 21:18 [Caml-list] A confusing example with modules and polymorphic variants Yaron Minsky
2012-10-19 22:10 ` Jeremy Yallop
2012-10-20  1:34   ` Yaron Minsky
2012-10-20  9:16   ` Gabriel Scherer
  -- strict thread matches above, loose matches on Subject: below --
2012-10-19 21:13 Yaron Minsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).