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 5BE9F7EE51 for ; Thu, 9 May 2013 01:35:17 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of milanst@gmail.com) identity=pra; client-ip=209.85.210.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of milanst@gmail.com designates 209.85.210.178 as permitted sender) identity=mailfrom; client-ip=209.85.210.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="milanst@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-ia0-f178.google.com) identity=helo; client-ip=209.85.210.178; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="milanst@gmail.com"; x-sender="postmaster@mail-ia0-f178.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvkBAIvfilHRVdKynGdsb2JhbABShnq8WAgWDgEBAQEBBg0JCRQogkkdARseAxIQDwImAiQBEQEFARYMiAwBAw+hVYJ2i25Pgn6EUQoZJw1Yh0cBBQyBGpBLgRMDlyyPUBYphFEg X-IPAS-Result: AvkBAIvfilHRVdKynGdsb2JhbABShnq8WAgWDgEBAQEBBg0JCRQogkkdARseAxIQDwImAiQBEQEFARYMiAwBAw+hVYJ2i25Pgn6EUQoZJw1Yh0cBBQyBGpBLgRMDlyyPUBYphFEg X-IronPort-AV: E=Sophos;i="4.87,636,1363129200"; d="scan'208";a="16570629" Received: from mail-ia0-f178.google.com ([209.85.210.178]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 09 May 2013 01:35:16 +0200 Received: by mail-ia0-f178.google.com with SMTP id t29so2491171iag.23 for ; Wed, 08 May 2013 16:35:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:from:date:message-id:subject:to :content-type; bh=XGLGSV22M6v6u2m7e2inUwBSxg2t8D7wTcQb9sAAtBs=; b=cPUUimC9YhhZZroP6ZxgRlpG0RHFlL80k4aEdf+Kpfs95QfvWoQDcR4AvODBiEn1+A gyfqhP/uIlmfhN5v39xHtwpV5dUUDDGKAdqM06OdZB34rIEu3/dTU/VoxqUdzY38h2Bc z7ZUfp6mNFknjdRn4x7jsJ76LzoALA4Rx2tBAegLgrAhVKormzgzLwl0k/AoS1y6BjlT H2eCP70nlCSsVXHgGhdUBOg/b55nD9kDQEFDPwNp7Id35uOWzY6s6L/iRUDe1wZg+hKn 3BFwFGARadyu7v5g/r50kNPojKWY34cHaL1LABlwu2zufblgRt+wWWoq4lvClmlaenwz BqFg== X-Received: by 10.50.153.74 with SMTP id ve10mr7001992igb.1.1368056115449; Wed, 08 May 2013 16:35:15 -0700 (PDT) MIME-Version: 1.0 Received: by 10.64.12.34 with HTTP; Wed, 8 May 2013 16:34:35 -0700 (PDT) From: =?UTF-8?Q?Milan_Stanojevi=C4=87?= Date: Wed, 8 May 2013 19:34:35 -0400 Message-ID: To: Caml List Content-Type: text/plain; charset=UTF-8 Subject: [Caml-list] an issue with coercing private types I have this module module Foo : sig type 'a t = private int end = struct type 'a t = int end and then I want to coerce Foo.t into int let to_int (a : 'a Foo.t) = (a :> int) 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 but this compiles fine let to_int a = (a : 'a Foo.t :> int) and gives me the right type. What is wrong with the first version of [to_int]? Is this a bug in the compiler? I'm using ocaml 4.0.1 I also tried this with Foo.t that doesn't have phantom type variable and in that case both versions of [to_int] work.