0 results from MLton.size
   
    Stephen Weeks
     
    MLton@sourcelight.com
       
    Tue, 6 Nov 2001 13:50:06 -0800
    
    
  
> I  remember  this  being  a  problem  discussed before, but is there any work
> around?  I have a huge hash table and am trying to figure out how big it  is.
> When I add the line
>     val _ = warn ("Table size " ^ Int.toString (MLton.size table))
> where warn just sends the result, along with a newline, to stderr, I get
>     Table size 0
The bad interactions happen with one-variant datatypes.
Can you send your hash table code?  Or are you using the lib/mlton
stuff?
One fix may be to add a size function that looks under the hood, as in
the following.
structure S:
   sig
      type t
      val new: int -> t
      val size: t -> int
   end =
   struct
      datatype t = T of int list
      fun new n = T (List.tabulate (n, fn i => i))
      fun size (T l) = MLton.size l
   end
val _ = print (concat [Int.toString (S.size (S.new 100)), "\n"])