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

private rows question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
 Date: 2005-11-11 (06:27) From: Keiko Nakata Subject: Re: [Caml-list] again private rows question
```Sorry, again...

What is the difference beteen the functor F and the function f ?
(F is not typable, but f is)

module F(X:sig
type t = private [< `A | `B | `C ]
val f : [`III ] -> t end) =
struct
let rec g  = function
[] -> []
| `I  :: tl -> `A :: (g tl)
| `II :: tl -> `B :: (g  tl)
| (`III as iii) :: tl  ->
let iii' = (X.f iii : [< `A | `B | `C ] :> [> `A | `B ]) in
iii' :: (g tl)
end

let f (x : [< `A | `B | `C]) = (x : [< `A | `B | `C] :> [> `A | `B]);;

I also curious to know whether there is a way to
make g's type depend on X.t in

module G(X:sig type t = private [< `A ] val f : int -> t end) = struct
let g x = if x = 0 then `B else X.f x
end

Regards,
Keiko NAKATA

```