From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 7E8467EE51 for ; Thu, 9 May 2013 05:53:05 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=pra; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of garrigue@math.nagoya-u.ac.jp) identity=mailfrom; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="garrigue@math.nagoya-u.ac.jp"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mailhost.math.nagoya-u.ac.jp) identity=helo; client-ip=133.6.130.5; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="garrigue@math.nagoya-u.ac.jp"; x-sender="postmaster@mailhost.math.nagoya-u.ac.jp"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AqIBAMAci1GFBoIFnGdsb2JhbABSgz6DPLt6gREOAQEBAQEIFAk8gh8BAQQBIyABNQIDCwsaAiYCAiE2BhOHegMJBQ2vK3KDUwKFAg1Lh1MHgSaLLIIjMweCQjJhiRuMMIFkgSaKbYhALQ X-IPAS-Result: AqIBAMAci1GFBoIFnGdsb2JhbABSgz6DPLt6gREOAQEBAQEIFAk8gh8BAQQBIyABNQIDCwsaAiYCAiE2BhOHegMJBQ2vK3KDUwKFAg1Lh1MHgSaLLIIjMweCQjJhiRuMMIFkgSaKbYhALQ X-IronPort-AV: E=Sophos;i="4.87,638,1363129200"; d="scan'208";a="16584329" Received: from rabbit.math.nagoya-u.ac.jp (HELO mailhost.math.nagoya-u.ac.jp) ([133.6.130.5]) by mail2-smtp-roc.national.inria.fr with ESMTP; 09 May 2013 05:53:03 +0200 Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 810FF638C; Thu, 9 May 2013 12:52:59 +0900 (JST) Received: from mailhost.math.nagoya-u.ac.jp (localhost [127.0.0.1]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id 7B85539A3; Thu, 9 May 2013 12:52:58 +0900 (JST) DomainKey-Signature: h=Received:Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References:To:X-Mailer; b=; c=nofws; d=math.nagoya-u.ac.jp; q=; s=alpha Received: from garrigue-mini.math.nagoya-u.ac.jp (garrigue-mini.math.nagoya-u.ac.jp [172.16.30.37]) by mailhost.math.nagoya-u.ac.jp (Postfix) with ESMTP id D2C95399B; Thu, 9 May 2013 12:52:57 +0900 (JST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 6.3 \(1503\)) From: Jacques Garrigue In-Reply-To: Date: Thu, 9 May 2013 12:53:00 +0900 Cc: Caml List Content-Transfer-Encoding: quoted-printable Message-Id: <42448548-6C1F-4008-AE02-6FD416FE7C32@math.nagoya-u.ac.jp> References: To: =?utf-8?Q?Milan_Stanojevi=C4=87?= X-Mailer: Apple Mail (2.1503) Subject: Re: [Caml-list] an issue with coercing private types On 2013/05/09, at 8:34, Milan Stanojevi=C4=87 wrote: > I have this module >=20 > module Foo : sig > type 'a t =3D private int > end =3D struct > type 'a t =3D int > end >=20 > and then I want to coerce Foo.t into int > let to_int (a : 'a Foo.t) =3D (a :> int) >=20 > this fails to compile with > Error: This expression cannot be coerced to type int; it has type 'a Foo.t > but is here used with type int >=20 > but this compiles fine > let to_int a =3D (a : 'a Foo.t :> int) >=20 > and gives me the right type. The reason one works and not the other is explained here: http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc76 Namely, when using single coercions from private type abbreviations, the type of the expression should not contain type variables. An interesting consequence is that the following is fine: let to_int (type a) (a : a Foo.t) =3D (a :> int);; Jacques Garrigue=