Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* [Caml-list] Help with recursive modules and functors
@ 2017-02-07 12:50 Phil Scott
  2017-02-08 11:52 ` Robert Atkey
  0 siblings, 1 reply; 3+ messages in thread
From: Phil Scott @ 2017-02-07 12:50 UTC (permalink / raw)
  To: caml-list

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.


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

end of thread, other threads:[~2017-02-08 22:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-07 12:50 [Caml-list] Help with recursive modules and functors Phil Scott
2017-02-08 11:52 ` Robert Atkey
2017-02-08 22:28   ` Phil Scott

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox