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
Variants recursifs et sous-typage #3147
Comments
Comment author: administrator
Les coercions simples ne marchent que dans les cas simples :-) let f x = (x :> nat);;val f : [< nat] -> nat = Sachant que [< nat] = [< La bonne solution est let f x = (x : one :> nat);;val f : one -> nat =
Quand tu unifie le premier type au second, tu commence par eliminer le cas Jacques |
Comment author: administrator On Wed, 13 Feb 2002, Jacques Garrigue wrote:
Ah ok, je pensais que si le contexte donnait un type "( x : one )",
C'est cela que je ne comprends pas. Éliminer Alain |
Comment author: administrator From: frisch@clipper.ens.fr
Euh... Ca supposerait qu'on sache defaire l'unification, ce qu'on ne Plus important: ca n'est bien sur pas principal. Il faudrait savoir
Je vois ton probleme: (x :> [< ... ]) est equivalent a Jacques |
Comment author: administrator Erratum:
Je melangeais avec Ctype.subtype. (x : [< t] :> [> t]) est une
Jacques |
Original bug ID: 802
Reporter: administrator
Status: closed
Resolution: not a bug
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Je ne sais pas si c'est un bug ou si j'ai raté quelque chose:
type nat = [
Z |
S of nat ]type zero = [
Z ] type one = [
S of zero ]let f (x : one) = (x :> nat)
donne:
This expression cannot be coerced to type nat = [
Z |
S of nat];it has type one = [
S of zero] but is here used with type [< nat] = [<
S of nat]Type zero = [
Z] is not compatible with type nat = [
Z | `S of nat]Alors que:
let f (x : [< one ]) = (x :> nat)
est accepté.
Est-ce normal ?
Là aussi, je ne comprends pas:
let f (x : [
S of [<
Z] ]) =(x :> ([<
Z |
S of 'a ] as 'a))donne
This expression cannot be coerced to type [<
S of 'a] as 'a; it has type [
S of [< `Z]]but is here used with type 'a
(d'où sort ce type ([< `S of 'a] as 'a) ?)
--
Alain
The text was updated successfully, but these errors were encountered: