caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Alain Frisch <alain@frisch.fr>
To: Fabrice Marchant <fabrice.marchant@orange.fr>
Cc: caml-list <caml-list@inria.fr>
Subject: Re: [Caml-list] A functor to produce recursive modules ?
Date: Fri, 23 May 2008 08:18:58 +0200	[thread overview]
Message-ID: <483661D2.9040301@frisch.fr> (raw)
In-Reply-To: <20080522225830.52208601@orange.fr>

Fabrice Marchant wrote:
> Hi !
>
>    Apologize. This topic isnt't exactly at its right place : belongs to Beginners-list.
> However no answer about this question there and so much clever people here, a denser traffic...
>
>    Please how to define recursive modules that are parametrized by an OrderedType ?
> Say these modules types are Mod and ModSet.
> (Because a function f in module Mod uses a Set of Mod)
>
> The problem is I need recursive functors that returns 2 modules.

I'm not sure to understand. Maybe a functor that returns a pair of 
mutually recursive modules is what you want.

module F(X : Set.OrderedType) = struct
   module rec Mod : sig
     type t = X of int * ModSet.t
     val compare: t -> t -> int
     val of_list: t list -> t
   end
     =
   struct
     type t = X of int * ModSet.t
     let compare (X (i, _)) (X (j, _)) = compare i j
     let of_list i l = X (i, List.fold_right ModSet.add l ModSet.empty)
   end
   and ModSet : Set.S with type elt = Mod.t = Set.Make(Mod)
end

-- Alain


  reply	other threads:[~2008-05-23  6:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-22 20:58 Fabrice Marchant
2008-05-23  6:18 ` Alain Frisch [this message]
2008-05-23 18:00   ` [Caml-list] " Fabrice Marchant
2008-05-23 19:40   ` Fabrice Marchant
2008-05-23 19:42   ` Fabrice Marchant
2008-05-23 22:02     ` Till Varoquaux
2008-05-23 21:37       ` Fabrice Marchant
2008-05-23 22:25     ` Jeremy Yallop
2008-05-23 21:37       ` Fabrice Marchant

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=483661D2.9040301@frisch.fr \
    --to=alain@frisch.fr \
    --cc=caml-list@inria.fr \
    --cc=fabrice.marchant@orange.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).