From: "Tom Primožič" <tom.primozic@gmail.com>
To: caml-list <caml-list@inria.fr>
Subject: How to compute variance of a type
Date: Sun, 6 Jan 2008 11:19:31 +0100 [thread overview]
Message-ID: <c1490a380801060219hc074ad0s46db833fa4410fe8@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 762 bytes --]
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?
[-- Attachment #2: Type: text/html, Size: 983 bytes --]
next reply other threads:[~2008-01-06 10:19 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-06 10:19 Tom Primožič [this message]
2008-01-06 12:44 ` [Caml-list] " rossberg
2008-01-06 15:31 ` Andrej Bauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c1490a380801060219hc074ad0s46db833fa4410fe8@mail.gmail.com \
--to=tom.primozic@gmail.com \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox