caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Defeating the value restriction
@ 2011-10-26 20:07 John Carr
  2011-10-26 20:22 ` Jeremy Yallop
  2011-10-28  0:05 ` Jacques Garrigue
  0 siblings, 2 replies; 3+ messages in thread
From: John Carr @ 2011-10-26 20:07 UTC (permalink / raw)
  To: caml-list


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)

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

end of thread, other threads:[~2011-10-28  0:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-26 20:07 [Caml-list] Defeating the value restriction John Carr
2011-10-26 20:22 ` Jeremy Yallop
2011-10-28  0:05 ` Jacques Garrigue

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).