Browse thread
Mutually recursive types in different modules
-
Andre Nathan
-
Jon Harrop
- Andre Nathan
- Arthur Chan
- Martin Jambon
-
Jon Harrop
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Arthur Chan <baguasquirrel@g...> |
| Subject: | Re: [Caml-list] Mutually recursive types in different modules |
As Jon demonstrates it is "possible," but I do not think it truly achieves
what you are trying to do. What is your use case? I do not recommend
trying to make types recursive across modules. Even recursively defined
modules have reared their ugly end on me. It is equivalent to writing
non-orthogonal code, in the functional paradigm (see Pragmatic Programmer).
On Mon, Jul 14, 2008 at 10:04 AM, Jon Harrop <jon@ffconsultancy.com> wrote:
> 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.
> http://www.ffconsultancy.com/products/?e
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>
--
-----------------------------------------------------------------------
(\__/)
(='.'=)This is Bunny. Copy and paste Bunny into your
(")_(")signature to help him gain world domination.
------------------------------------------------------------------------