标准 SML 库函数 Int.toString 以负数为前缀,~而不是-。是否有一个库函数可以-代替,没有写
fun i2s i =
if i < 0 then "-" ^ Int.toString (~i) else Int.toString i
In short, No.
SML is designed to use ~ for unary minus to avoid confusion with - (binary minus). It's a sensible decision when you have each operator for only one purpose and SML users have to live with that.
Although it's strange to read a string representation of an integer starting with ~, there's no library function to convert it to a string in the normal convention. BTW, your function is a good way to do so.