English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
RE: Record typing question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-11-04 (17:53)
From: Don Syme <dsyme@m...>
Subject: RE: Record typing question

>Spooky, I raised this point a few days ago!

Ah ha - I see that now.  I haven't been keeping up to date with the
discussion list!

>    type 'a foo = { a: 'a; b: 'a }
>    let f x = { x with a = 1 }

> Here "f: 'a foo -> int foo" won't wash, because the "b" field will
> stay an int, contra the definition.  Before lifting the current
> restriction, one would have to check that no type equalities between
> fields are broken.

I guess it should be f: int foo -> int foo.  All the field assignments would
act in parallel as far as the type system goes, so

    type 'a foo = { a: 'a; b: 'a; c: int }
    let f x = { x with a = [x.a]; b = [x.b]  }

would be f: 'a foo -> 'a list foo