From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by walapai.inria.fr (8.13.6/8.13.6) with ESMTP id p7EDiTdh031542 for ; Sun, 14 Aug 2011 15:44:29 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlYCAMnQR07RVaE2kGdsb2JhbABBp3AIFAEBAQEJCQ0HFAQhgVkCExkBGx4DEhBeEQEFASI1h1ACkniCVAqMNoJVg0o7iG0CAwaFYl8EkxKGNIYlPINi X-IronPort-AV: E=Sophos;i="4.67,369,1309730400"; d="scan'208";a="115816682" Received: from mail-fx0-f54.google.com ([209.85.161.54]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 14 Aug 2011 15:44:24 +0200 Received: by fxe4 with SMTP id 4so5915992fxe.27 for ; Sun, 14 Aug 2011 06:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; bh=EuoPFdWP5KdAdaU8wldV+i2zZyX3QNffohJMvWLktCE=; b=WtbN52B1/fKUmrFZFZD5ikHNSUFX1e9r5c2edfBh0EQygEWo4Ih4SWo0jgDIPvhVno KFXcCYL6dCUlAt2y+xueTKKtkd0RhbgVI4+4LnxB5eAZK9VxpXzk51yPRePmiKijb5qv /YqrAtFsmB4u8AYAimC/m5qZT8VgbbLawZi7Q= Received: by 10.223.145.144 with SMTP id d16mr4065874fav.100.1313329463659; Sun, 14 Aug 2011 06:44:23 -0700 (PDT) Received: from ruslan-macbook.lan (ppp-93-104-69-209.dynamic.mnet-online.de [93.104.69.209]) by mx.google.com with ESMTPS id r12sm2942723fam.14.2011.08.14.06.44.21 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 14 Aug 2011 06:44:22 -0700 (PDT) From: Ruslan Ledesma Garza Content-Type: text/plain; charset=iso-8859-1 Date: Sun, 14 Aug 2011 15:46:23 +0200 Message-Id: <1F991690-DC08-4BF6-BB41-6B9402C043FC@gmail.com> To: OCaml List Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by walapai.inria.fr id p7EDiTdh031542 Subject: [Caml-list] Type generalization problem Dear list, Consider the following OCaml session. Objective Caml version 3.12.0 # let f : 'v . 'v -> 'v = fun x -> x;; val f : 'a -> 'a = # let g : 'v . 'v -> 'v = (fun x -> x) (fun x -> x);; Error: This definition has type 'a -> 'a which is less general than 'b. 'b -> 'b # Why doesn't OCaml generalize the type 'a -> 'a? According to the typing rules in "Principal type-schemes for functional programs" ( http://portal.acm.org/citation.cfm?id=582176 ), the type 'a -> 'a can be generalized. Something similar happens in the following OCaml session. Objective Caml version 3.12.0 # let f : 'v . 'v -> 'v = fun x -> x;; val f : 'a -> 'a = # let h = f f;; val h : '_a -> '_a = # h 1;; - : int = 1 # h h;; Error: This expression has type int -> int but an expression was expected of type int # I want the type of h to be \forall 'a . 'a -> 'a. :'( Best regards, Ruslán.