Version française
Home     About     Download     Resources     Contact us    
Browse thread
using functors in objects
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Julien Signoles <Julien.Signoles@l...>
Subject: Re: [Caml-list] using functors in objects

> Perhaps something like this with recursive modules. I have a feeling it
> can be simplified, though.
>
> Andrej
>
> --------------------
> module A (X: sig type t end) =
> struct
>  class c =
>  object
>    val b = (None : X.t option)
>  end
> end
>
> module rec D : sig
>  class d : object val b : D.d option end
> end =
> struct
>  class d =
>  object
>    inherit Y.c
>  end
> end
>
> and Y :
> sig
>  class c : object val b : D.d option end
> end =
>  A(struct type t = D.d end)
>
> class d = D.d
>
> ----------------

it doesn't work because the recursive modules cannot be safely 
initialized in such a case:

$ ocamlc -v
The Objective Caml compiler, version 3.10.1
Standard library directory: /home/jsignole/local/godi/lib/ocaml/std-lib
$ ocamlc -o modclass modclass.ml
$ ./modclass
Fatal error: exception Undefined_recursive_module("modclass.ml", 23, 2)

Yet I haven't a good solution for such a think :-(.

--
Julien