caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Problem with Functors and Module Types
@ 2008-08-01 11:10 Christian Sternagel
  2008-08-01 11:58 ` [Caml-list] " Julien Signoles
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Sternagel @ 2008-08-01 11:10 UTC (permalink / raw)
  To: caml-list

Hello,

once again I have some problems using functors with module types. I 
produced following (almost?) minimal example:

     module type MT_M = sig
      type s
      type t = A of s | B of t list
      val f : t -> t
     end

     module type MT_N = sig
      module M : MT_M
      val f : 'a -> M.t
     end

     module type MT_A = sig
      type t
     end

     module MakeM (A : MT_A) : MT_M with type s = A.t = struct
      type s = A.t
      type t = A of s | B of t list
      let f x = x
     end

     module MakeN (A : MT_A) (* : MT_N *) = struct
      module M = MakeM (A)
      let f _ = M.B []
     end

     module A = struct
      type t = int
     end

     module M = MakeM (A)
     module N = MakeN (A)

     let _ = (M.f (N.f 1))

This file compiles, but when I comment-in the module type restriction 
for `MakeN' the error

This expression has type N.M.t = MakeN(A).M.t but is here used with type
   M.t = MakeM(A).t

occurs. I understand that in the current setting the two types are not 
equal for the compiler. However, my question is: Is there a way to tell 
the compiler that the two types should be equal?

cheers

christian


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

end of thread, other threads:[~2008-08-01 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-01 11:10 Problem with Functors and Module Types Christian Sternagel
2008-08-01 11:58 ` [Caml-list] " Julien Signoles

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