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 AEC887EE51 for ; Mon, 27 May 2013 18:30:29 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of jp.deplaix@gmail.com) identity=pra; client-ip=209.85.214.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jp.deplaix@gmail.com"; x-sender="jp.deplaix@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of jp.deplaix@gmail.com designates 209.85.214.54 as permitted sender) identity=mailfrom; client-ip=209.85.214.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jp.deplaix@gmail.com"; x-sender="jp.deplaix@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-bk0-f54.google.com) identity=helo; client-ip=209.85.214.54; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="jp.deplaix@gmail.com"; x-sender="postmaster@mail-bk0-f54.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ag8CAH+Jo1HRVdY2jmdsb2JhbABahnOFXrlyFg4BAQEBBw0JCRIGJIJNBBkBGxwCAxIDBgEGFhYLAgsDAgECARERAQUBIg0IAQGHdgEDDgGQaow/gnmLcE+CfYQpChknDViIDAEFDJFZgRMDlzuGHok9P4Q3 X-IPAS-Result: Ag8CAH+Jo1HRVdY2jmdsb2JhbABahnOFXrlyFg4BAQEBBw0JCRIGJIJNBBkBGxwCAxIDBgEGFhYLAgsDAgECARERAQUBIg0IAQGHdgEDDgGQaow/gnmLcE+CfYQpChknDViIDAEFDJFZgRMDlzuGHok9P4Q3 X-IronPort-AV: E=Sophos;i="4.87,752,1363129200"; d="scan'208,217";a="19171675" Received: from mail-bk0-f54.google.com ([209.85.214.54]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 May 2013 18:30:29 +0200 Received: by mail-bk0-f54.google.com with SMTP id it16so3374536bkc.41 for ; Mon, 27 May 2013 09:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type; bh=Sn2eD+KjvEWtTLA/bp6jBpyDq0lUHYMpQQA6Mx41L3s=; b=kK2YIYYlqmhmw4LepPoKlG2DsCe63VsQghU8wBeIbzncjED0yMdJjswgmh7S5DidtW CW7cYdYIJX5pGyofAZv0FJWtc4uS9HCL/3FKlINoCtqZZ5vVzJi7iUi590Zx7E3BFn9j zsQnPj+1evXQHaFLrYBz84prWGXTV2P2150XIVAzL2H5OEr6aeGA08xaOgmRmNn+V/nL GHM0mcr9wjh4KyCJ58df+cHg2ceZO7grV27yFq+sZE5qRfU/yrNHSHy7JLZsUI03Z5o8 Jy0p+RTXkCq7uM7O9KnShkSXlFuUb8wZr+vLsvm41QtNtJj3xC/TXT8O23H/BxXEikgV Y0rw== X-Received: by 10.204.166.133 with SMTP id m5mr12425735bky.78.1369672228713; Mon, 27 May 2013 09:30:28 -0700 (PDT) Received: from [10.41.126.17] ([163.5.219.50]) by mx.google.com with ESMTPSA id i15sm8685982bkz.12.2013.05.27.09.30.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 May 2013 09:30:27 -0700 (PDT) Message-ID: <51A38A23.9000402@gmail.com> Date: Mon, 27 May 2013 18:30:27 +0200 From: Jacques-Pascal Deplaix User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130306 Thunderbird/17.0.3 MIME-Version: 1.0 To: OCaml mailing list X-Enigmail-Version: 1.5 Content-Type: multipart/alternative; boundary="------------040607080107060603080600" Subject: [Caml-list] Recursive fixed polymorphic variants This is a multi-part message in MIME format. --------------040607080107060603080600 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi, I have a problem with this test-case which doesn't compile: module M : sig type a = [`A] type 'a b = [`B of 'a] val a : unit -> a val b : 'a -> 'a b end = struct type a = [`A] type 'a b = [`B of 'a ] let a () = `A let b x = `B x end;; let rec f = function `B x -> f x | `A -> ();; f (M.b (M.a ()));; and produce the following error: Error: This expression has type M.a M.b = [ `B of M.a ] but an expression was expected of type [< `B of 'a ] as 'a Type M.a = [ `A ] is not compatible with type M.a M.b = [ `B of M.a ] These two variant types have no intersection The thing is, if we define M.a and M.b with « unit -> [> a ] » and « 'a -> [> 'a b ] », it does compile but I don't know why the previous code doesn't. Does somebody have any hints ? --------------040607080107060603080600 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit Hi,

I have a problem with this test-case which doesn't compile:

module M : sig
  type a = [`A]
  type 'a b = [`B of 'a]

  val a : unit -> a
  val b : 'a -> 'a b
end = struct
  type a = [`A]
  type 'a b = [`B of 'a ]

  let a () = `A
  let b x = `B x
end;;

let rec f = function `B x -> f x | `A -> ();;

f (M.b (M.a ()));;


and produce the following error:

Error: This expression has type M.a M.b = [ `B of M.a ]
       but an expression was expected of type [< `B of 'a ] as 'a
       Type M.a = [ `A ] is not compatible with type M.a M.b = [ `B of M.a ]
       These two variant types have no intersection

The thing is, if we define M.a and M.b with « unit -> [> a ] » and « 'a -> [> 'a b ] », it does compile but I don't know why the previous code doesn't.

Does somebody have any hints ?
--------------040607080107060603080600--