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
[newbie] Define and use records in sum types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: Recursive Sets?
On Wed, 02 Aug 2000, Michael Welsh Duggan wrote:
> I have been trying to create a recursive type which can express sets
> of itself.  The following code is not meant to be correct (it isn't),
> but hopefully expresses the sort of thing I want to do.  Can someone
> throw some ideas at me?

I am afraid, but it is not possible to have mutually recursive module
and type definitions. See the following entry in the archive:

I don't know what exactly you want to do. Some time ago I implemented a
referentially transparent directory service that might be similar to what
you want to implement, e.g.:

                        /  |  |  \
                      a    b  \   c
                      |   /    f
                      d  e    /|\
                             g h i

It is possible to update nodes directly without losing persistence. E.g.:

  let dir1 = (* directory as above,
                the "current working directory" is "root" *) in
  let dir2 = Dir.cd_path dir1 ["f"; "h"; "x"] ...

This will keep "dir1" unchanged, but "dir2" will look as follows (the
CWD will be "root/f/h/x"):

                        /  |  |  \
                      a    b  \   c
                      |   /    f
                      d  e    /|\
                             g h i

You can parameterize the directory over arbitrary ordered elements. If it
is something like this you need, I could place it online (though, it is
part of a larger project that I'll release in a few weeks, anyway - not
much time right now)...

Markus Mottl

Markus Mottl,,