[Ur] common type for different functor instantiations
Adam Chlipala
adamc at impredicative.com
Wed Oct 26 19:26:01 EDT 2011
Gergely Buday wrote:
> I have the following problem:
>
> record ::: {Type} is fixed, [data] is dependent on [record] and
> [MspecificFields]
>
> I have a functor, that, among others, contain
>
> functor Render (M: sig
> con MspecificFields :: {Type}
> val renderMspecific : $MspecificFields -> xbody
> end )
> : sig
> render : data -> xbody
> end
>
> I call this for three different M, but now I want to rewrite it so
> that the resulting module has the signature
>
> sig
> type mRecord
> getRecord : data -> mRecord
> render : mRecord -> mRecord -> xbody
> end
>
> so that the caller can store the previous value of mRecord and the
> render function can compare the fresh and the stored. Since the
> argument structures differ in some fields, I cannot declare a common
> type for mRecord, or, at least, I do not see how I could.
>
> Is there a solution for this in ur/web?
>
Sure: define [mRecord] outside the functor completely. It could be an
abstract type in an enclosing module. (Modules can contain functors,
which can contain modules that contain functors, and so on ad infinitum.)
More information about the Ur
mailing list