[Caml-list] Structural subtyping problem

2010-03-28 Thread Dario Teixeira
Hi, I'm using the structural subtyping aspects of Ocaml's object system to emulate width subtyping. I've come across a problem which does not type-check, though intuitively it seems correct. I reckon that the compiler may need some help in the form of type annotations and/or coercions,

Re: [Caml-list] Structural subtyping problem

2010-03-28 Thread Vincent Aravantinos
Hi, the following seems to do the trick (?) : Le 28 mars 10 à 18:38, Dario Teixeira a écrit : let rec step1 ?story () = match story with | Some s - step2 s#title | None - step2 title1 and step2 title = let story = object

Re: [Caml-list] Structural subtyping problem

2010-03-28 Thread Stéphane Glondu
Dario Teixeira a écrit : A simple nonsensical example that illustrates the problem is listed below; the type-checking error occurs in function step1, where the optional parameter story is used as an object of type title:string; .. . In function step3, this parameter story is actually

Re: [Caml-list] Structural subtyping problem

2010-03-28 Thread Christophe TROESTLER
Hi, On Sun, 28 Mar 2010 19:32:37 +0200, Stéphane Glondu wrote: type steps = { step1 : 'a. ?story:(title : string; .. as 'a) - unit - bool; step2 : string - bool; step3 : 'a. story:(title : string; count : int; .. as 'a) - bool } let rec steps = { [...] IMHO, recursive modules

Re: [Caml-list] Structural subtyping problem

2010-03-28 Thread Dario Teixeira
Hi, I'm using the structural subtyping aspects of Ocaml's object system to emulate width subtyping.  I've come across a problem which does not type-check, though intuitively it seems correct.  I reckon that the compiler may need some help in the form of type annotations and/or