From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=HTML_MESSAGE autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id D51FABBC1 for ; Fri, 2 May 2008 19:35:37 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AkMCAB/uGkhA6bjhd2dsb2JhbACCNTaOeQEMBQIECQ8FlACFPQ X-IronPort-AV: E=Sophos;i="4.27,427,1204498800"; d="scan'208";a="25768310" Received: from wr-out-0506.google.com ([64.233.184.225]) by mail4-smtp-sop.national.inria.fr with ESMTP; 02 May 2008 19:35:37 +0200 Received: by wr-out-0506.google.com with SMTP id c30so1057208wra.21 for ; Fri, 02 May 2008 10:35:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:mime-version:content-type; bh=NQLHSBmagDnQuKRWbrdwo1i3p8BOabmD6UD7Ss4F4U0=; b=TFWfQHUyNZmaZI+AEKF5LTdhsTSD6br2B26OAcAGXxqiiftodqdRP77tJcT4eOIUWZvTJD9ylza+d48ObGNS3cgbYCMQhDoE3bIPZyMHkg0mXpxv2eO9m2TCxzkoJBnrCGugmIoltIujkyd4DodioPX8ehbosdBnznRrgwNCk8E= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=KDfOC9LxSzUg7MWnZwOdwsIKB0nUNE8rZ3inQdAFiYB2J+wRa9SFbF9a3SpfELqqm+3pJ5uLUtCyCStyHr37fNUhfRsMEvuFsBxBCg1h34uda5+UWDXts5oGOixTg3INQzebVx9d+gm5GmFwzrKCpwWGReTywaSS1cXd59fQGOE= Received: by 10.100.212.13 with SMTP id k13mr5030860ang.28.1209749735518; Fri, 02 May 2008 10:35:35 -0700 (PDT) Received: by 10.100.216.8 with HTTP; Fri, 2 May 2008 10:35:35 -0700 (PDT) Message-ID: Date: Fri, 2 May 2008 13:35:35 -0400 From: "Jacques Le Normand" To: "caml-list caml-list" Subject: question about polymorphic variants MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_18049_30968491.1209749735491" X-Spam: no; 0.00; variants:01 foo:01 foo:01 ocaml:01 coerced:01 ocaml:01 coerced:01 polymorphic:01 caml-list:01 caml-list:01 int:01 int:01 variant:02 variant:02 expression:02 ------=_Part_18049_30968491.1209749735491 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello caml-list, when I try to run the following code: type sometype = ([ `Foo of int | `Bar of int | `Var of 'a ref ] as 'a) type someother = ([ `Foo of int | `Var of 'a ref ] as 'a) let foo : someother = `Foo 5;; (foo :> sometype) in my ocaml repl, it gives me the following error This expression cannot be coerced to type sometype = [ `Bar of int | `Foo of int | `Var of sometype ref ]; it has type someother = [ `Foo of int | `Var of someother ref ] but is here used with type [< sometype ] = [< `Foo of int | `Var of sometype ref ] Type someother = [ `Foo of int | `Var of someother ref ] is not compatible with type sometype = [ `Bar of int | `Foo of int | `Var of sometype ref ] The first variant type does not allow tag(s) `Bar how do I get around this? ------=_Part_18049_30968491.1209749735491 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Hello caml-list,
when I try to run the following code:


type sometype =
  ([
    `Foo of int
  | `Bar of int
  | `Var of 'a ref
  ] as 'a)
type someother =
  ([
    `Foo of int
  | `Var of 'a ref
  ] as 'a)

let foo : someother = `Foo 5;;
(foo :> sometype)

in my ocaml repl, it gives me the following error

This expression cannot be coerced to type
  sometype = [ `Bar of int | `Foo of int | `Var of sometype ref ];
it has type someother = [ `Foo of int | `Var of someother ref ]
but is here used with type
  [< sometype ] = [< `Foo of int | `Var of sometype ref ]
Type someother = [ `Foo of int | `Var of someother ref ]
is not compatible with type
  sometype = [ `Bar of int | `Foo of int | `Var of sometype ref ]
The first variant type does not allow tag(s) `Bar



how do I get around this?
------=_Part_18049_30968491.1209749735491--