From: John Carr <jfc@mit.edu>
To: caml-list@inria.fr
Subject: [Caml-list] Defeating the value restriction
Date: Wed, 26 Oct 2011 16:07:12 -0400 [thread overview]
Message-ID: <201110262007.p9QK7CMd028545@outgoing.mit.edu> (raw)
Can I rewrite this function to have the type I requested
instead of failing type checking?
let f : ('a * 'a -> 'a) -> int * bool = fun x -> x (0,1), x (true,false)
I assume the type error is caused by the value restriction.
The parameter (x) becomes monomorphic when applied, so it
can not be applied to both types (int*int) and (bool*bool).
A top level syntactic function
let x : ('a * 'a -> 'a) = fun (a,b) -> a
retains its original, generalized type under similar circumstances.
My real example that fails type checking is more complicated.
I believe the root cause is the same.
--John Carr (jfc@mit.edu)
next reply other threads:[~2011-10-26 20:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-26 20:07 John Carr [this message]
2011-10-26 20:22 ` Jeremy Yallop
2011-10-28 0:05 ` Jacques Garrigue
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=201110262007.p9QK7CMd028545@outgoing.mit.edu \
--to=jfc@mit.edu \
--cc=caml-list@inria.fr \
/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