From: Romain Bardou <romain@bardou.fr>
To: caml-list@inria.fr
Subject: [Caml-list] Why doesn't relaxed value restriction apply here?
Date: Sat, 21 Apr 2018 10:41:29 +0200 [thread overview]
Message-ID: <2a9e479f-4ce0-fdf3-d0b7-501398691720@bardou.fr> (raw)
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
next reply other threads:[~2018-04-21 8:41 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-21 8:41 Romain Bardou [this message]
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
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=2a9e479f-4ce0-fdf3-d0b7-501398691720@bardou.fr \
--to=romain@bardou.fr \
--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