Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* How to compute variance of a type
@ 2008-01-06 10:19 Tom Primožič
  2008-01-06 12:44 ` [Caml-list] " rossberg
  2008-01-06 15:31 ` Andrej Bauer
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Primožič @ 2008-01-06 10:19 UTC (permalink / raw)
  To: caml-list

[-- 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 --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-01-06 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-01-06 10:19 How to compute variance of a type Tom Primožič
2008-01-06 12:44 ` [Caml-list] " rossberg
2008-01-06 15:31 ` Andrej Bauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox