caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain.Frisch@ens.fr
To: skaller <skaller@ozemail.com.au>
Cc: Caml list <caml-list@inria.fr>
Subject: Re: [Caml-list] inference engine
Date: Sun, 14 Sep 2003 11:48:15 +0200 (MET DST)	[thread overview]
Message-ID: <Pine.SOL.4.44.0309141135150.7473-100000@clipper.ens.fr> (raw)
In-Reply-To: <1063512749.23073.28.camel@pelican>

On 14 Sep 2003, skaller wrote:

> I'll try. At present, with
>
> 	let f (x:int) = x +. 1.0
>
> the inference engine goes:

I keep wondering if you're trying some kind of troll here, or if you're
serious. When you're saying "At present the inference engine goes..", what
do you mean? Have you tried your examples with the actual OCaml type
checker?

As a matter of fact, the type checker performs unification with the
constraints on arguments of functions as soon as possible. You don't need
any extra notion like 'mandatory typing' to do this.

>
> 	let f (x:int) * = x .+ 1.0 --> x is 'a
> 	let f (x:int) = x .+ * 1.0 --> 'a is restricted to float
> 	let f (x:int*) = x +. 1.0 --> float is restricted to int ERROR
>
> where the * marks the position in the analysis: the constraint of
> x to int is applied *after* the type is already deduced.

No, that's not how it works. Try the example with OCaml.

> To do that I'm suggesting to give x the type 'at least an int',
> meaning any subsequent typing of x in the function body
> must be constrainable to int -- and that is checked every time
> additional information is obtained by the inference engine
> to refine the type.

Do you know about unification?

> For another example:

OCaml does report the error where you expect. Try the example with OCaml.

> in particular, in the case like:
>
> 	let rec f1 (x1:t1):r1 = ..
> 	and f2 (x2:t2):r2 = ...
> 	and f3 (x2:t3):r3 = ..
> 	...
> 	and f999 (x999:t999):r999 = ...
>
> the fact the the constraints t1, r1, t2, t2, ..
> are not applied until after the whole recursion
> is typed

Again, this is wrong.


-- Alain

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


  parent reply	other threads:[~2003-09-14  9:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-13  6:58 skaller
2003-09-13 10:01 ` David Baelde
2003-09-14  4:12   ` skaller
2003-09-14  9:29     ` Remi Vanicat
2003-09-14  9:48     ` Alain.Frisch [this message]
2003-09-16 19:46       ` skaller
2003-09-21 16:45         ` skaller
2003-09-21 20:43           ` Remi Vanicat

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=Pine.SOL.4.44.0309141135150.7473-100000@clipper.ens.fr \
    --to=alain.frisch@ens.fr \
    --cc=caml-list@inria.fr \
    --cc=skaller@ozemail.com.au \
    /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).