Browse thread
covariance newb question
-
Christophe Papazian
- Keiko Nakata
-
Christophe Raffalli
- Olivier Andrieu
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Olivier Andrieu <oandrieu@n...> |
| Subject: | Re: [Caml-list] covariance newb question |
Christophe Raffalli [Monday 28 November 2005] :
> first 'a -> 'b is covariant in 'a and contravariant in 'b and Ocaml
It's the opposite (contravariant in 'a, covariant in 'b) :
,----
| # type (+'a, -'b) t = 'a -> 'b ;;
| Characters 5-28:
| type (+'a, -'b) t = 'a -> 'b ;;
| ^^^^^^^^^^^^^^^^^^^^^^^
| In this definition, expected parameter variances are not satisfied.
| The 1st type parameter was expected to be covariant,
| but it is contravariant
| # type (-'a, +'b) t = 'a -> 'b ;;
| type ('a, 'b) t = 'a -> 'b
`----
--
Olivier