caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: bluestorm <bluestorm.dylc@gmail.com>
To: Alexander Bernauer <bernauer@inf.ethz.ch>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] type of high order functions
Date: Thu, 16 Dec 2010 09:46:53 +0100	[thread overview]
Message-ID: <AANLkTimy_+DOH8XuTiwOoUipAojEqHAGdTiy9AyPx6XY@mail.gmail.com> (raw)
In-Reply-To: <20101216083217.GC29535@apus.ethz.ch>

[-- Attachment #1: Type: text/plain, Size: 1151 bytes --]

On Thu, Dec 16, 2010 at 9:32 AM, Alexander Bernauer <bernauer@inf.ethz.ch>wrote:

> If I don't specify a type, what's the inferred type of f? If I restrict
> f to the exact same type it should do no harm. At least, that is what I
> expected.


As Alain explained, the annotation you wrote is *not* the exact same type.
It's a different type where the scope of the 'a variable is wider, and
therefore less general. If you want to have the same semantics as the
inferred type (that is, a type variable quantified in the "let"
declaration-side but not use-side), you must use one of the
recently-introduced variable scoping constructs.

You're right that the scope rules for type inference variables are muddy at
best. This long underestimated issue has recently been under investigation,
as you can see with Alain's proposal (both syntaxes being only available
since the latest 3.12 version of OCaml), or the "Lexically scoped type
variables" [1] paper in the Haskell community (which describes and compare
the mutually incompatible behaviors of SML, Haskell and OCaml).

 [1]
http://research.microsoft.com/en-us/um/people/simonpj/papers/scoped-tyvars/

[-- Attachment #2: Type: text/html, Size: 1681 bytes --]

  reply	other threads:[~2010-12-16  8:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14 20:30 Alexander Bernauer
2010-12-15  8:31 ` [Caml-list] " Florent Ouchet
2010-12-16  8:32   ` Alexander Bernauer
2010-12-16  8:46     ` bluestorm [this message]
2010-12-15  8:32 ` Alain Frisch

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=AANLkTimy_+DOH8XuTiwOoUipAojEqHAGdTiy9AyPx6XY@mail.gmail.com \
    --to=bluestorm.dylc@gmail.com \
    --cc=bernauer@inf.ethz.ch \
    --cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).