caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* small typing problem with modules ...
@ 2009-05-26  9:37 Pietro Abate
  2009-05-26 12:37 ` [Caml-list] " Julien Signoles
  0 siblings, 1 reply; 4+ messages in thread
From: Pietro Abate @ 2009-05-26  9:37 UTC (permalink / raw)
  To: caml-list

Hi all,

I'm trying to build a functorized version of a library providing also 
a default type. Consider the two follwoing modules :

~$cat a.ml       
module type T = sig
    type extra
    val f : extra -> unit
end

module type Extra = sig
    type t = private [>  ]
    val g : t -> unit
end

module Make (Extra : Extra) = struct
   type extra = Extra.t
   let f t = ()
end

module ExtraDefault = struct
   type t = [`A]
   let g t = ()
end

include Make(ExtraDefault)

~$cat a.mli
module type T = sig
    type extra
    val f : extra -> unit
end

module type Extra = sig
    type t = private [>  ]
    val g : t -> unit
end

module ExtraDefault : Extra with type t = [ `A ]

module Make : functor (Extra : Extra) -> T with type extra = Extra.t
include T with type extra = ExtraDefault.t

------------------

so far so good. Now I've another module that I can type as follows:

~$cat b.ml 
module Make (Extra : A.Extra) (A : A.T with type extra = Extra.t) = struct
    open A
    let f t = ()
end

include Make(A.ExtraDefault)(A)

~$cat b.mli
module Make :
    functor (Extra : A.Extra) ->
        functor (A : A.T with type extra  = Extra.t) ->
    sig
      open A
      val f : extra -> unit
    end

open A
val f : extra -> unit

------------------------

My problem here is that I'd like to have a module type T for the functor
Make in b.ml and to avoid the signature duplication in b.mli ... ideally
I'd like to write in b.mli something like :

module type T = sig ???? end
module Make : functor (Extra : A.Extra) -> 
functor (A : A.T with type extra  = Extra.t) -> T with ...
include T with ...

It's clear that I cannot write a module type as follows because the 
the "open A" will consider the default type of A and not it's
parametrized version ...

module type T = sig
  open A
  val f : extra -> unit
end

how can I parametrize this signature ? I can write something like :
module type T = functor (A : A.T) -> 
  sig
    open A
    val f : extra -> unit 
end ;;

but then I'm a bit lost putting all this together ... 
I know I'm close ... a small hint ?

TA.
p


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

end of thread, other threads:[~2009-05-26 13:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-05-26  9:37 small typing problem with modules Pietro Abate
2009-05-26 12:37 ` [Caml-list] " Julien Signoles
2009-05-26 13:12   ` Pietro Abate
2009-05-26 13:35   ` Andreas Rossberg

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