Version française
Home     About     Download     Resources     Contact us    

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

Browse thread
Re: circular types?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Tom Hirschowitz <hirschow@m...>
Subject: Re: circular types?
> Nope, no forwards in Ocaml. At some point, you'll have to tie the recursive 
> knot with an "and". If the problem you're having is that "far away" means 
> "in different modules" then you bump into the lack of recursive modules, 
> IMO the biggest PITA with ML style modules.


I'm pleased to see I'm not working for nobody. 
Actually I'm not working exactly on recursive modules, but rather on 
mixin modules.
Instead of defining your two modules and then link them, you would 
create a new one with the holes filled.
For instance, for Brain's example, you would write something like : 

mixin A = 
    deferred module CompositeSet : sig type t ... end
    type composite = { data : string ; children : CompositeSet.t }

mixin B = 
    deferred type composite
    module CompositeSet = 
        type t = C of composite | D

mixin C = A + B

In fact, this one is too difficult for me right now, because it 
relies on a mutual dependency between a type and a module.
Since I'm just beginning this, I would really be pleased by any 
comments, suggestions or questions about it.