From: Lauri Alanko <la@iki.fi>
To: caml-list@inria.fr
Subject: [Caml-list] Functor applications cannot be opened
Date: Wed, 30 Mar 2011 05:50:09 +0300 [thread overview]
Message-ID: <20110330025009.GA5064@melkinpaasi.cs.helsinki.fi> (raw)
I have a signature that uses types from a functor applied to a member
of the signature:
module type T = sig
type t
end
module F(M : T) = struct
type l = M.t list
end
module type S = sig
module M : T
val x : F(M).l
end
I would like to get the types in F(M) into scope to avoid putting the
functor application everywhere:
module type S = sig
module M : T
open F(M)
val x : l
end
However, this does not work, since [open] takes only a module-path,
not an extended-module-path. There are workarounds:
module type S2 = sig
module M : T
module FM : module type of F(M)
open FM
val x : l
end
This, however, requires that an implementation of S2 contains [module
FM = F(M)], and we may need to add that constraint elsewhere, too.
Alternatively:
module SF(M : T) = struct
module FM = F(M)
open FM
module type S = sig
val x : l
end
end
And then use [SF(X).S] instead of [S with module M = X]. But this is
ugly, and precludes use with unknown M.
Is there some fundamental reason why opening of functor applications
is forbidden, or is this just an oversight and I should submit a
feature ticket?
Lauri
next reply other threads:[~2011-03-30 2:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-30 2:50 Lauri Alanko [this message]
2011-03-30 6:39 ` Joel Reymont
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=20110330025009.GA5064@melkinpaasi.cs.helsinki.fi \
--to=la@iki.fi \
--cc=caml-list@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