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=1.2 required=5.0 tests=AWL,HTML_MESSAGE,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 7FEB9BC6B for ; Sun, 6 Jan 2008 11:19:33 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKY5gEfAXQImh2dsb2JhbACCOTaNKwEBAQgKKZJShGY X-IronPort-AV: E=Sophos;i="4.24,250,1196636400"; d="scan'208";a="5759365" Received: from discorde.inria.fr ([192.93.2.38]) by mail2-smtp-roc.national.inria.fr with ESMTP; 06 Jan 2008 11:19:33 +0100 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id m06AJWhF005550 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Sun, 6 Jan 2008 11:19:33 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AgAAAKY5gEfRVca7kmdsb2JhbACCOTaNKwEBAQEHBAQpklSEZg X-IronPort-AV: E=Sophos;i="4.24,250,1196636400"; d="scan'208";a="7476217" Received: from rv-out-0910.google.com ([209.85.198.187]) by mail3-smtp-sop.national.inria.fr with ESMTP; 06 Jan 2008 11:19:32 +0100 Received: by rv-out-0910.google.com with SMTP id g11so5024861rvb.57 for ; Sun, 06 Jan 2008 02:19:31 -0800 (PST) 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=XoeNEHjXHK7Hi5NbU2IktvAv+VzRRCnZ3ySpihDC1RA=; b=OU6PV4kYHzQIONx54hVOCuExxBmv5LWpN4+FoSfjJaXfqTf/QPq17EqbMxOyZZ735PkW8RZqjt9yRrrOVMPSz9quu4e4to4YUf0r/ydN/5Ft3asYdeXLuJrn1xDHpn2vSpW9YLRn69kSPJ6La7rtUxnYB0RX5hMI0i3QRWGCZ7Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=o1Z3Ka5d4dtIA3QZeyZC6F4EYEwtQb+mZK7IcWtcpA5hmAlZp53TOVzIpvUlpfuRv0ojS/wKrof5ETbs8Y/lVsDEqVwiZfmCLzlg6YxijWfbT4nPXuDRRvyq07AqO7fLUG5qLj8QwR2fssS0l0x/88nmrmT7HHTzTm3coClL8bQ= Received: by 10.141.36.10 with SMTP id o10mr4440220rvj.176.1199614771189; Sun, 06 Jan 2008 02:19:31 -0800 (PST) Received: by 10.140.172.20 with HTTP; Sun, 6 Jan 2008 02:19:31 -0800 (PST) Message-ID: Date: Sun, 6 Jan 2008 11:19:31 +0100 From: "=?UTF-8?Q?Tom_Primo=C5=BEi=C4=8D?=" To: caml-list Subject: How to compute variance of a type MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_16017_6799375.1199614771188" X-Miltered: at discorde with ID 4780AB34.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; inference:01 ml-like:01 funct:01 funct:01 inference:01 ml-like:01 covariant:02 covariant:02 parameters:03 parameters:03 complex:05 complex:05 types:05 types:05 variable:06 X-Attachments: cset="UTF-8" cset="UTF-8" ------=_Part_16017_6799375.1199614771188 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline I am writing a type inference engine for a simple ML-like language, and I am wondering how to infer the variance of type parameters. I know a little about variance already, so I could figure it out for some basic cases, like in type type ('a, 'b) funct = 'a -> 'b the type variable 'a is contravariant, and 'b is covariant, and in case one variable would be co- and contravariant at the same time, it is invariant type ('a, 'b) both = Left of 'a -> 'b | Right of 'b -> 'a. But I have no idea on how to compute variance of complex types, like type ('a, 'b, 'c) long_funct = ('a -> 'b) -> 'c since the whole ('a -> 'b) is in contravariant position, so 'a is twice contravariant, and b is first contra-, and the covariant. Any resources? ------=_Part_16017_6799375.1199614771188 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline I am writing a type inference engine for a simple ML-like language, and I am wondering how to infer the variance of type parameters. I know a little about variance already, so I could figure it out for some basic cases, like in type

    type ('a, 'b) funct = 'a -> 'b

the type variable 'a is contravariant, and 'b is covariant, and in case one variable would be co- and contravariant at the same time, it is invariant

    type ('a, 'b) both   =   Left of 'a -> 'b   |   Right of 'b -> 'a.

But I have no idea on how to compute variance of complex types, like

    type ('a, 'b, 'c) long_funct = ('a -> 'b) -> 'c

since the whole ('a -> 'b) is in contravariant position, so 'a is twice contravariant, and b is first contra-, and the covariant.

Any resources?
------=_Part_16017_6799375.1199614771188--