[MLton-devel] phantom types and directed graphs

Stephen Weeks MLton@mlton.org
Mon, 10 Feb 2003 22:07:13 -0800


I was thinking of using phantom types to improve the static checking
of directed graphs.  The idea is to parameterize the graph type with a
phantom parameter that will let us give different graphs different
types.  This will help detect errors in confusing nodes from different
graphs.  Each graph transformation will allow a new type of graph to
be produced.

signature DIRECTED_GRAPH = 
   sig
      structure Node: 
	 sig
	    type 'a t
	 end
      
      type 'a t

      val new: unit -> unit t
      val newNode: 'a t -> 'a Node.t
      val nodes: 'a t -> 'a Node.t list
      val transpose: 'a t -> 'b t * {destroy: unit -> unit,
				     newNode: 'a Node.t -> 'b Node.t}
   end

To use it, whenever you want a new graph type, you write down a
datatype and constrain the result of the graph operation.

Any thoughts?  Better ways to do it?


-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel