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 are also a nice way to achieve the same
effect :
module rec X :
sig
val step1 : ?story:<title : string; ..> -> unit -> bool
val step2 : string -> bool
val step3 : story:<title : string; count : int; ..> -> bool
end = struct
let rec step1 ?story () = match story with
| Some s -> X.step2 s#title
| None -> X.step2 "title1"
and step2 title =
let story = object
method title = title
method count = 0
end in
X.step3 story
and step3 ~story = match story#count with
| 0 -> X.step1 ~story ()
| 1 ->
let story = object
method title = "title2"
end in
X.step1 ~story ()
| _ -> true
end
My 0.02€,
C.
_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs