Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <filliatr@lri.fr>
To: aXl <krauth@fmi.uni-passau.de>
Cc: caml-list@inria.fr
Subject: Re: Typing-problem
Date: Mon, 31 May 1999 12:37:39 +0200 (MEST)	[thread overview]
Message-ID: <14162.26227.300552.10117@pc89.lri.fr> (raw)
In-Reply-To: <Pine.GSO.3.96.990530171304.16161A-100000@kosh>


> why is in the following example b of type "string -> string" ?
> 
> 	let a = id id;;
> 	let b = a;;
> 	a "foo";; 
> 	(* until here it's covered by the faq's *)
> 	b;;

It is because:

  1. the type variable is not generalized is the type of a;
     (it is '_a -> '_a)

  2. that type variable is shared between the types of a and b

Therefore when applying a to "foo", that type variable is instanciated
by string, which instanciates also the type of b.

A more detailed explanation is given here :

  http://caml.inria.fr/FAQ/FAQ_EXPERT-eng.html#polymorphisme

Best regards,
-- 
Jean-Christophe FILLIATRE
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr




  reply	other threads:[~1999-06-01 15:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-30 15:24 Typing-problem aXl
1999-05-31 10:37 ` Jean-Christophe Filliatre [this message]
1999-05-31 12:42 ` Typing-problem hubert.fauque

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=14162.26227.300552.10117@pc89.lri.fr \
    --to=filliatr@lri.fr \
    --cc=Jean-Christophe.Filliatre@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=krauth@fmi.uni-passau.de \
    /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