New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
type faible et covariance #8151
Comments
Comment author: administrator From: vanicat@labri.u-bordeaux.fr
Ce comportement est effectivement decrit dans le papier sur le
La variance des parametres de format reste pour moi un grand Jacques |
Comment author: administrator Fixed by JG (2003-05-21) |
Comment author: administrator From: vanicat@labri.u-bordeaux.fr
Ce comportement etant incorrect dans le cas d'une abbreviation (il est
|
Original bug ID: 1692
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Bonjours,
Suite a un message récent sur la mailing list, j'ai voulue trouver ce
qu'il fallait pour qu'une application partielle de kprintf donne un
type polymorphe, et je suis tombé sur une étrangeté :
type (-'a, 'b, 'c, 'd) my_format;;
type (-'a, 'b, 'c, 'd) my_format
let from_my (x: ('a, 'b, 'c, 'd) my_format) =
val from_my : ('a, 'b, 'c, 'd) my_format -> ('a, 'b, 'c, 'd) format =
let to_my (x :('a, 'b, 'c, 'd)format) =
val to_my : ('a, 'b, 'c, 'd) format -> ('a, 'b, 'c, 'd) my_format =
let mykprintf k fo = Printf.kprintf k (from_my fo);;
val mykprintf : (string -> 'a) -> ('b, unit, string, 'a) my_format -> 'b =
let m = mykprintf (fun s -> prerr_endline s);;
val m : ('_a, unit, string, unit) my_format -> '_a =
type 'a t = ('a, unit, string, unit) my_format -> 'a;;
type 'a t = ('a, unit, string, unit) my_format -> 'a
let (m: 'a t) = mykprintf (fun s -> prerr_endline s);;
val m : 'a t =
On voit que l'application partielle de mykrintf donne un type
polymorphique faible alors que si on la type explicitement, à l'aide
d'un type nommé, cela devient un type polymorphique complet.
Il semble donc que l'algorithme utilisé pour détecter la covariance ne
soit pas le même pour décider de la distinction typage fort/typage
faible dans le cas d'une application partielle que dans le cas d'une
définition du type.
Ps: mon message n'implique en aucun cas que je pense que format
devrais être contravariant en son premier argument. J'en sais rien,
c'était juste un test
--
Rémi Vanicat
vanicat@labri.u-bordeaux.fr
http://dept-info.labri.u-bordeaux.fr/~vanicat
The text was updated successfully, but these errors were encountered: