[MLton-devel] cvs commit: phantom types and directed graphs

Stephen Weeks MLton@mlton.org
Tue, 11 Feb 2003 21:47:14 -0800


> Just to be pedantic, the fact that the monomorphizer is fooled by the
> phantom type into extra duplication is an argument for it to not duplicate
> over all types, but over all representations.

I don't disagree with you in principle.  But given that MLton decides
representations so late in the game, I don't see anything even
remotely easy to do in practice.

BTW, the bogus duplication really can occur.  Below is a simple
example.  If you compile -keep-pass mono, you will see two copies of
h.  I'll think about how easy it would be to fix the monomorphiser (or
maybe do a prepass).

structure S:>
   sig
      type 'a t
      type 'a u

      val f: unit -> 'a t

      datatype 'a res = Res of 'a t * int
      val h: 'a t -> 'a res
   end =
   struct
      type t = int

      fun f () = 0

      datatype 'a res = Res of t * int
      fun h i = Res (i, i)

      type 'a t = t
      type 'a u = unit
   end

open S
val Res (s, _): unit res = h (f ())
val Res (s, _): int res = h (f ())


-------------------------------------------------------
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