[MLton] cvs commit: major improvements to -show-basis
Matthew Fluet
fluet@cs.cornell.edu
Thu, 12 Feb 2004 09:38:22 -0500 (EST)
> Please try this out, both for the basis library and for user programs
> and send bug reports and suggestions for improvement.
Abstract types in signatures are displayed as type equalities:
signature ARRAY2 =
sig
type 'a array = 'a array
...
end
I'm confused by the "= 'a array"; it seems to suggest a type equality with
the top-level array, but that is clearly incorrect. I'd prefer to see
signature ARRAY2 =
sig
eqtype 'a array
end
"Bad defaults" for equivalent types:
signature BIN_IO =
sig
type elem = BinIO.elem
type instream = instream
type outstream = outstream
type vector = BinIO.vector
...
structure StreamIO: STREAM_IO
where type elem = BinIO.elem
where type instream = StreamIO.instream
where type out_pos = StreamIO.out_pos
where type outstream = StreamIO.outstream
where type pos = StreamIO.pos
where type reader = StreamIO.reader
where type vector = BinIO.vector
where type writer = StreamIO.writer
end
Note that basis-library/io/bin-io.sig defines BIN_IO as:
signature BIN_IO =
sig
structure StreamIO: BIN_STREAM_IO
type elem = StreamIO.elem
type instream
type outstream
type vector = StreamIO.vector
...
end
and basis-library/io/bin-stream-io.sig defines BIN_STREAM_IO as
signature BIN_STREAM_IO =
STREAM_IO
where type elem = Word8Vector.elem
where type vector = Word8Vector.vector
So, it's rather confusing to see BinIO.elem and BinIO.vector appearing in
the signature for BIN_IO. Also, the issue with abstract types leads to
further confusion.
The "bad defaults" leads to a very odd BYTE signature:
signature BYTE =
sig
val byteToChar: BinIO.elem -> char
val bytesToString: BinIO.vector -> string
val charToByte: char -> BinIO.elem
val packString: (BinPrimIO.array * int * substring) -> unit
val stringToBytes: string -> BinIO.vector
val unpackString: BinPrimIO.array_slice -> string
val unpackStringVec: BinPrimIO.vector_slice -> string
end
Implementation type of Socket.SOCK.sock_type is exposed:
signature GENERIC_SOCK =
sig
val socket: (NetHostDB.addr_family * int) -> ('a, 'b) Socket.sock
val socket': (NetHostDB.addr_family * int * int)
-> ('a, 'b) Socket.sock
val socketPair: (NetHostDB.addr_family * int)
-> (('a, 'b) Socket.sock * ('a, 'b) Socket.sock)
val socketPair': (NetHostDB.addr_family * int * int)
-> (('a, 'b) Socket.sock * ('a, 'b) Socket.sock)
end
The first int in each tuple should be the (abstract)
Socket.SOCK.sock_type.