Version française
Home     About     Download     Resources     Contact us    
Browse thread
Module type of a structure returned by functor
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dawid Toton <d0@w...>
Subject: Module type of a structure returned by functor
1. The following piece of code contains illegal constructs. These are 
functor applications marked with (* ? *).
     Basically, I need module type of what is produced by functor.
     My first question is: what is the proper, "canonical" workaround 
for unavailability of applications marked (* ? *) ?

module type Big = sig type t type u end
module type Small = sig type t end

module type MakeEdge = functor (Big : Big) -> sig val foo : Big.t option end
module MakeEdge = functor (Big : Big) -> struct let foo = None end

module type Add_boilerplate = functor (Small:Small) -> sig type t end
module Add_boilerplate = functor (Small:Small) -> struct type t = 
Small.t type u = t end

module type ConvenientEdge = functor (Small:Small) -> MakeEdge 
(Add_boilerplate (Small)) (* ? *)
module ConvenientEdge = functor (Small:Small) -> MakeEdge 
(Add_boilerplate (Small))

module SmallX = struct type t = int end
module EdgeX = ConvenientEdge (SmallX)
module type EdgeX = ConvenientEdge (SmallX) (* ? *)

module Algorithm = functor (EdgeX : EdgeX) -> struct let doit = 
EdgeX.foo end


2. And the related question: why one can't do functor applications in 
module types as in above lines marked with (* ? *) ? Is there some 
theoretical reason?

3. Will the "module type of..." feature of 3.12 help with this? I can 
imagine e.g.:

module type EdgeX = (module type of (ConvenientEdge (SmallX)))


Dawid