Version française
Home     About     Download     Resources     Contact us    
Browse thread
recursive modules?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jacques Garrigue <garrigue@m...>
Subject: Re: [Caml-list] recursive modules?
From: "L.G. Meredith" <lgreg.meredith@gmail.com>

> i'm mostly a neophyte with OCaml. Please find below a simple example of a
> code i would like to be able to write, but that the compiler will not eat. i
> build a term language over a set of variables that are themselves abstractly
> characterized in terms of some identifier type. i would like to write a
> recursive module in which the abstract type of identifier is essentially the
> type of the joinedcompositionfunctor applied to itself. One can show that
> this results in a (mathematically) well-founded definition. Is there a
> version of OCaml or an OCaml compiler option that will enable this kind of
> recursive definition?

RTFM :-) Recursive modules are in the "language extensions" chapter.

Here is what I believe should be your module (if I understood
correctly your intent.)

module rec VariableOfRJoinedComposition :
    (IDENTIFIER with type idType =
        JoinedCompositionFunctor(VariableOfRJoinedComposition).composite)
= struct

  module RJoinedCompositionEquivalence =
    Equivalence ( JoinedCompositionFunctor )( VariableOfRJoinedComposition )

  type idType = RJoinedCompositionEquivalence.JoinedComposition.composite
  let comparator =
    RJoinedCompositionEquivalence.structural

end