caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Functor applications cannot be opened
@ 2011-03-30  2:50 Lauri Alanko
  2011-03-30  6:39 ` Joel Reymont
  0 siblings, 1 reply; 2+ messages in thread
From: Lauri Alanko @ 2011-03-30  2:50 UTC (permalink / raw)
  To: caml-list

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] Functor applications cannot be opened
  2011-03-30  2:50 [Caml-list] Functor applications cannot be opened Lauri Alanko
@ 2011-03-30  6:39 ` Joel Reymont
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Reymont @ 2011-03-30  6:39 UTC (permalink / raw)
  To: Lauri Alanko; +Cc: caml-list


On Mar 30, 2011, at 3:50 AM, Lauri Alanko wrote:

> 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

http://www.math.nagoya-u.ac.jp/~garrigue/papers/ml2010-show.pdf

module type S = sig
 module M : T
 include module type of F(M)
 val x : l
end

--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-03-30  6:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-30  2:50 [Caml-list] Functor applications cannot be opened Lauri Alanko
2011-03-30  6:39 ` Joel Reymont

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).