Version française
Home     About     Download     Resources     Contact us    
Browse thread
parameterized signatures
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris Tilt <cet@w...>
Subject: parameterized signatures
Bonjour. S'il vous plaît pardon le manque de Français aujourd'hui.

I have read (although poorly understood) the recent postings regarding
the need for parameterized signatures, which I think would help. Please
let me ask the question a different way.

Is there a way to refer to the type of a functor defined by a .mli file
in another .mli file? I am attempting to build a parameterized type and
they build a sub-type which will provide a specific implementation of
that signature. My problem is in expressing the interface of the second
type to use the constructed type from the first file.

Since some people have asked for a generalized graph module, and I also
have the need, I am trying to package one. Here is a snipet to help
explain my question. The issue is in the very last line.

Sorry for the long post and example. BTW, this code is being used in
production of a real product! Thank you all for your support of a great
programming language!

Merci, Chris

---- pgraph.mli ----
(* supply the core graph functionality *)
module type ParameterizedGraphType =
    type t
    type edge
    type vertex
    val compare: t -> t -> int

module type S =
    type vid
    type pEdge
    type vertex = Vertex of vid * pVertex
    type edge = Edge of vid * vid * pEdge
    type t
    type graph = t
    ... some functions ...

module Make : functor (Param: ParameterizedGraphType) ->
  (S with type vid = Param.t
     and type pVertex = Param.vertex
     and type pEdge = Param.edge)

---- -----
implements pgraph.mli in the usual way

---- -----
(* use the ParameterizedGraphType module (Pgraph) to build a custom
   graph which has Html.window values as vertex attributes. This is
   used by the old-generation profiler product *)
module type WindowGraphType =
    type t = string
    type vertex = Html.window
    type edge = float * float
    val compare: string -> string -> int

=====> the problem area. How do I express the type of this module?
module type Wgraph = Pgraph.S ???