[MLton-devel] phantom types and directed graphs
Stephen Weeks
MLton@mlton.org
Mon, 10 Feb 2003 22:28:44 -0800
> Sounds good, but don't all users of phantom types have to be polymorphic?
> That means that they have to be let-bound. It could be that that is the case
> any way.
I don't quite understand your question, but the way I envision Graph
being used is like this:
------------------------------------------------------------
signature DIRECTED_GRAPH =
sig
structure Node:
sig
type 'a t
end
type 'a t
val new: unit -> 'a 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
functor F (G: DIRECTED_GRAPH) =
struct
datatype t = T
val g: t G.t = G.new ()
val n = G.newNode g
datatype t = T
val (g': t G.t, {destroy, newNode}) = G.transpose g
val _ = newNode n (* notice that newNode (newNode n) fails *)
end
------------------------------------------------------------
So, you see that whenever I want to distinguish between graph types, I
create new types and constrain the graphs.
-------------------------------------------------------
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