From: Phil Scott <phil.scott@ed.ac.uk>
To: caml-list@inria.fr
Subject: [Caml-list] Help with recursive modules and functors
Date: Tue, 07 Feb 2017 12:50:23 +0000 [thread overview]
Message-ID: <87tw86rwq8.fsf@ed.ac.uk> (raw)
Hi all.
Suppose I have the following code:
module type Foo = functor(S : sig type s val foo : s -> s end) ->
sig
type t
end
module Bar =
functor(F: Foo) ->
struct
module rec S :
sig
type s = int
type baz = Baz of F(S).t
val foo : s -> s
end =
struct
type s = int
type baz = Baz of F(S).t
let foo x = x
end
end
Here, I want my Bar module to apply its supplied Foo to a recursive
module S. However, I am being told that the functor application F(S) in
the signature for S is ill-typed. The problems are apparently due to the
type of baz in the signature. If I change the type so that it doesn't
involve F(S), the type-checker is happy:
module Bar =
functor(F: Foo) ->
struct
module rec S :
sig
type s = int
type baz = Baz
val foo : s -> s
end =
struct
type s = int
type baz = Baz
let foo x = x
end
end
But this is odd to me, since baz is not even in the signature of Foo's
argument, so I don't understand how it's type could affect the type
correctness of the functor application. Can anyone explain to me what
the problem is? I understand that I'm probably pushing what recursive
modules can do, but would like some details if anyone can clear it up
for me.
Thanks!
--
Phil Scott
Centre for Intelligent Systems and their Applications
University of Edinburgh
--
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.
next reply other threads:[~2017-02-07 12:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-07 12:50 Phil Scott [this message]
2017-02-08 11:52 ` Robert Atkey
2017-02-08 22:28 ` Phil Scott
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=87tw86rwq8.fsf@ed.ac.uk \
--to=phil.scott@ed.ac.uk \
--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