Version française
Home     About     Download     Resources     Contact us    
Browse thread
module types and constraints in several layers
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christian Sternagel <christian.sternagel@u...>
Subject: Re: [Caml-list] module types and constraints in several layers
On Thu, Mar 15, 2007 at 09:48:44AM -0500, Chris King wrote:
> On 3/15/07, Christian Sternagel <christian.sternagel@uibk.ac.at> wrote:
> >some.ml:
> >module Make (Trs : TRS.T) : SOME.T = struct
> 
> This looks to be your problem... by specifying the type of Trs as
> TRS.T, you are losing the information about the relation between the
> types in the modules.  You can fix this by adding this relation to the
> definition of TRS.T:
> 
> module type T = sig
> type t
> module Term: TERM.T
> module Fun : FUNCTION.T with type t = Term.Fun.t
> val f0 : t -> Fun.t Setx.set
> end
> 
> Otherwise O'Caml presumes Term and Fun to be completely unrelated.
> 
> Hope this helps; module type constraints can get messy :)
Thanks this helped a lot... no the only open problem is how
to constrain variant types.

i have 
module type TERM
 module Var : VAR
 module Fun : FUN
 module Lab : LAB
  with type t = Fun.Lab.t

 type t = Var of Var.t | Fun of Fun.t * t list
end

and in the module type  TRS I need to do something like

module type TRS
 module Rule : RULE
 module Term : TERM
  with module Var = Rule.Var
  and module Fun = Rule.Fun
  and module Lab = Rule.Lab
  and type t = Rule.Term.t
               ^^^^^^^^^^^

which yields a syntax error... is there a way to give such a 
constraint for variant types?

cheers

christian
> 
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>