From: Yaron Minsky <yminsky@janestreet.com>
To: caml-list@inria.fr
Cc: Stephen Weeks <sweeks@janestreet.com>,
David Powers <dpowers@janestreet.com>,
Nathan Linger <nlinger@janestreet.com>
Subject: [Caml-list] A confusing example with modules and polymorphic variants
Date: Fri, 19 Oct 2012 17:18:19 -0400 [thread overview]
Message-ID: <CACLX4jTDY+Y40vwHAxh-tspRn8FaR+ZaGAE+totOz283c7b+1w@mail.gmail.com> (raw)
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?
next reply other threads:[~2012-10-19 21:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-19 21:18 Yaron Minsky [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACLX4jTDY+Y40vwHAxh-tspRn8FaR+ZaGAE+totOz283c7b+1w@mail.gmail.com \
--to=yminsky@janestreet.com \
--cc=caml-list@inria.fr \
--cc=dpowers@janestreet.com \
--cc=nlinger@janestreet.com \
--cc=sweeks@janestreet.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox