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
Mutually recursive types in different modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-07-14 (17:05)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] Mutually recursive types in different modules
On Monday 14 July 2008 17:50:02 Andre Nathan wrote:
> Hello
> Say I have the following type definition:
>   type a = { x: int; foo: b } and  b = { y: int; bar: a }
> Is it possible to define types a and b in their own files (thus in
> modules A and B) and still allow them to be mutually recursive?

Yes. See the OCaml Journal article "Tricks with recursion: knots, modules and 
polymorphism" or Google for the phrase "untying the recursive knot".

Dr Jon D Harrop, Flying Frog Consultancy Ltd.