caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Dawid Toton <d0@wp.pl>
To: caml-list <caml-list@yquem.inria.fr>
Subject: Module type of a structure returned by functor
Date: Sat, 24 Apr 2010 01:14:44 +0200	[thread overview]
Message-ID: <4BD229E4.4050003@wp.pl> (raw)

1. The following piece of code contains illegal constructs. These are 
functor applications marked with (* ? *).
     Basically, I need module type of what is produced by functor.
     My first question is: what is the proper, "canonical" workaround 
for unavailability of applications marked (* ? *) ?

module type Big = sig type t type u end
module type Small = sig type t end

module type MakeEdge = functor (Big : Big) -> sig val foo : Big.t option end
module MakeEdge = functor (Big : Big) -> struct let foo = None end

module type Add_boilerplate = functor (Small:Small) -> sig type t end
module Add_boilerplate = functor (Small:Small) -> struct type t = 
Small.t type u = t end

module type ConvenientEdge = functor (Small:Small) -> MakeEdge 
(Add_boilerplate (Small)) (* ? *)
module ConvenientEdge = functor (Small:Small) -> MakeEdge 
(Add_boilerplate (Small))

module SmallX = struct type t = int end
module EdgeX = ConvenientEdge (SmallX)
module type EdgeX = ConvenientEdge (SmallX) (* ? *)

module Algorithm = functor (EdgeX : EdgeX) -> struct let doit = 
EdgeX.foo end


2. And the related question: why one can't do functor applications in 
module types as in above lines marked with (* ? *) ? Is there some 
theoretical reason?

3. Will the "module type of..." feature of 3.12 help with this? I can 
imagine e.g.:

module type EdgeX = (module type of (ConvenientEdge (SmallX)))


Dawid


             reply	other threads:[~2010-04-23 23:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-23 23:14 Dawid Toton [this message]
2010-04-26 16:33 ` Dawid Toton
2010-04-26 16:48   ` [Caml-list] " Vincent Aravantinos
2010-04-26 16:54   ` rossberg
2010-04-27  0:23 ` [Caml-list] " Jacques Garrigue

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=4BD229E4.4050003@wp.pl \
    --to=d0@wp.pl \
    --cc=caml-list@yquem.inria.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).