Re: Recursive Variants of Set

"Jacques du Preez [email protected] [ocaml_beginners]" <[email protected]>
Newsgroups gmane.comp.lang.ocaml.beginners
Message-ID <CAMBKu=e+q0M-mjsewy5=i9s9mBoQ6GnC5KyN_xfDPmNBWeRutg@mail.gmail.com>
Thank you so much Gabriel. I'll have a look at that. Thanks!

==============================
Jacques du Preez

Web: OpenLandscape.net
EMail: [email protected]
Twitter: @jacquesdp


On Sat, Jul 12, 2014 at 5:20 PM, Gabriel Scherer [email protected]
[ocaml_beginners] <[email protected]> wrote:

>
>
> It is not correct to use the name of a compilation unit (.ml{,i} files)
> from within its own code: the cause of the circular dependency error here
> is the use of paths of the form Common.foo.
>
> To recursively define a type and sets over it, you should use recursive
> modules. This is actually the example given in the manual for recursive
> modules:
>   http://caml.inria.fr/pub/docs/manual-ocaml/extn.html#sec220
>
>
> On Sat, Jul 12, 2014 at 5:13 PM, Jacques du Preez [email protected]
> [ocaml_beginners] <[email protected]> wrote:
>
>>
>>
>> Hi,
>>
>> Please consider my common.mli:
>>
>> type id = | Id of Common.Id_set.t
>>           | Common of string
>>   | ObjStore of string
>>
>> module Id_set : (Set.S with type elt = id)
>>
>> Now my common.ml:
>>
>> type id = | Id of Common.Id_set.t
>>           | Common of string
>>   | ObjStore of string
>>
>> module Id_set = Set.Make(
>>     struct
>>       type t = id
>>       let compare = Pervasives.compare
>>     end)
>>
>> The above gives an circular build error. If I change Common.Id_set.t to
>> Id_set.t, then I get an unbound module error - I'm assuming this is because
>> the Id_set module declaration is after the variant declaration.
>>
>> What I'd like to know is, how would I change my Id variant to be of type
>> "id set"? Is this possible? The problem here is that Id_set depends on
>> variant id, and vice versa. How to solve this?
>>
>> Thanks,
>>
>> ==============================
>> Jacques du Preez
>>
>> Web: OpenLandscape.net
>> Twitter: @jacquesdp
>>
>>
>>
>  
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.