caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Why doesn't relaxed value restriction apply here?
@ 2018-04-21  8:41 Romain Bardou
  2018-04-21  9:04 ` Jeremy Yallop
  0 siblings, 1 reply; 5+ messages in thread
From: Romain Bardou @ 2018-04-21  8:41 UTC (permalink / raw)
  To: caml-list

Hello,

According to the manual 
(http://caml.inria.fr/pub/docs/manual-ocaml/polymorphism.html) and to 
the paper "Relaxing the Value Restriction" 
(http://caml.inria.fr/pub/papers/garrigue-value_restriction-fiwflp04.pdf), 
the relaxed value restriction allows to generalize type variables which 
only appear in covariant positions.

The following code :

     let f = let _ = ref 0 in fun f -> f []

returns the following in the toplevel:

     val f : ('_a list -> '_b) -> '_b = <fun>

In this type, '_a only appears in covariant position. So, why is it not 
generalized?

Sorry if this has been asked already, I could not find anything. I'm 
sure there is a simple explanation. I can't find out whether:
- I'm stupid and '_a actually appears in a non-covariant position;
- I'm stupid and read the rule about relaxed value restriction wrong;
- or the relaxed value restriction which was implemented is not actually 
the one which is described in the manual and in the paper.

Cheers,

-- 
Romain Bardou

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa.inria.fr/sympa/arc/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

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

end of thread, other threads:[~2018-04-21 11:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-21  8:41 [Caml-list] Why doesn't relaxed value restriction apply here? Romain Bardou
2018-04-21  9:04 ` Jeremy Yallop
2018-04-21  9:14   ` Romain Bardou
2018-04-21  9:45     ` Jeremy Yallop
2018-04-21 11:34       ` Romain Bardou

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