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 mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by sympa.inria.fr (Postfix) with ESMTPS id F0A067F1C3 for ; Tue, 27 Nov 2012 12:00:43 +0100 (CET) Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of lambda.q.q@gmail.com) identity=pra; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail1-smtp-roc.national.inria.fr: domain of lambda.q.q@gmail.com designates 209.85.217.182 as permitted sender) identity=mailfrom; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="lambda.q.q@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail1-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-lb0-f182.google.com) identity=helo; client-ip=209.85.217.182; receiver=mail1-smtp-roc.national.inria.fr; envelope-from="lambda.q.q@gmail.com"; x-sender="postmaster@mail-lb0-f182.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AocBAL2ctFDRVdm2m2dsb2JhbAA7CcAfCCQBAQEBAQgJCwkUJ4JMEwYBOQMNBSY0AQQgAQUBFogaAw8EnwKCbI4hgQqFPycNiU4BBQyMOYEIgycDiFiJd4MyjmQ/gVeCPg X-IronPort-AV: E=Sophos;i="4.83,328,1352070000"; d="scan'208";a="183413503" Received: from mail-lb0-f182.google.com ([209.85.217.182]) by mail1-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Nov 2012 12:00:43 +0100 Received: by mail-lb0-f182.google.com with SMTP id go10so12559497lbb.27 for ; Tue, 27 Nov 2012 03:00:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=uS+S4H5+kmFlKJxZn/hHAymLPBGp2XUJ51xy/2X/qoI=; b=gelumZsoBpFmWpmeojf3sx67BipVsO4qIybN6BjHNtO58EX2eLvW+JpNBiGh/tTboV YVM1VlY5aaavJedwdKXL7cHQ/Uqq8/orAnBYav+DGto3cD6tUds/buhgxr+aM0uKrlgl DUPvdGSFag2Es6qVOJq+YAwq23xwQQwd/Qd9qXodnU5uMzRKfBUq+c/Aa50neaU8E06/ x1e7YrtyXOl3980obB7QTbsAxslfgrP2ldYAagt0NRHKfADndjFnKweVDUmcn0IwkG0I 4JfFTz87eaD0COf0TrcTlIh3LYQE09YWnzzloYNyT3IIECWxwXN0x+JQkY1WnIjDNJ7M Zt+Q== Received: by 10.112.9.135 with SMTP id z7mr6320609lba.66.1354014042334; Tue, 27 Nov 2012 03:00:42 -0800 (PST) Received: from golf.niidar.ru.niidar.ru ([178.176.235.48]) by mx.google.com with ESMTPS id e4sm6839244lby.12.2012.11.27.03.00.40 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 27 Nov 2012 03:00:41 -0800 (PST) Sender: Ivan Gotovchits From: Ivan Gotovchits To: caml-list@inria.fr Date: Tue, 27 Nov 2012 15:00:35 +0400 Message-ID: <87ip8rwbsc.fsf@golf.niidar.ru> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: [Caml-list] phantom types and identity function Hello, These simple signature module type T = sig type 'a t constraint 'a = [< `A | `B ] val init: [`A] t val f: [`A] t -> [`B] t end can be used to constrain the following module module T : T = struct type 'a t = unit constraint 'a = [< `A | `B] let init = () let f x = x end where identity function successfully satisfies the constraint [`A] t -> [`B] t but in the following module module T : T = struct type 'a t = {x:int} constraint 'a = [< `A | `B] let init = {x=0} let f x = x end the same identity function doesn't satisfy. I'll be genuinelly happy, if somebody clarify this issue for me :) My guess is that the problem lies in the field of higher order polymorpism, and instead the identity function with signature 'a -> 'a, a more polymorphic function 'a -> 'b should be used. Though this contradicts with the fact that the identity function works fine in the first example and brings up another problem, which is how to obtain such polymorphic function... Thanks in advance! -- (__) (oo) /------\/ / | || * /\---/\ ~~ ~~ ...."Have you mooed today?"...