I have written a generic function and now I want the string representation of the generic variables. Is there an easy way to get them?
For example:
fun arg:(string*'a) = (#1 arg) ^ toString((#2 arg)
That is what I want to do basically.
So if that method is called with ("hello", true") I want “hellotrue” out. And if there is more complex structure I want that printed out if possible.
The short answer is no.
Unlike Haskell, SML doesn’t have type classes and it is not possible to derive for example show of new types.
The “only” way is to create a specific show or toString function for each type you create.
I say “only” as MLton has a pretty nice article on type indexed values