This site is updated infrequently. For up-to-date information, please visit the new OCaml website at ocaml.org.

[Caml-list] extensible records again
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2004-03-24 (09:14) From: Julien Signoles Subject: Re: [Caml-list] extensible records again
```
> > type x = [`A of +x | `B ]
> > type y = [x | `C ]
>
> might be encoded as
>
> module type Xrec = sig type t end
> module X0(Xrec : Xrec) =
>   struct type t0 = Xrec.t type t = [`A of t0 | `B] end
> module type Xsig = sig type t0 type t = [`A of t0 | `B] end
> module rec X : (Xsig with type t0 = X.t) = X0(X)
> module Y0(Xrec : Xrec) =
>   struct
>     module XY = X0(Xrec)
>     type t0 = Xrec.t
>     type t = [XY.t | `C]
>   end
> module type Ysig = ???
> module rec Y : (Xsig with type t0 = Y.t) = Y0(Y)

(* [...] *)
module type Ysig = sig
module XY : Xsig
type t0
type t = [ XY.t | `C]
end
module rec Y : (Ysig with module XY = X0(Y) and type t0 = Y.t) = Y0(Y)

somethink: I think you don't use t0 in Y0 and Ysig because t0 is enclosed
in XY. I would write somethink like:

(* [...] *)
module Y0(Xrec : Xrec) = struct
module XY = X0(Xrec)
type t = [XY.t | `C]
end
module type Ysig = sig
module XY : Xsig
type t = [ XY.t | `C]
end
module rec Y : (Ysig with module XY = X0(Y)) = Y0(Y)

Julien
--
mailto:Julien.Signoles@lri.fr ; http://www.lri.fr/~signoles
"In theory, practice and theory are the same,
but in practice they are different" (Larry McVoy)

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

```