I’m trying to read text from a file in SML. Eventually, I want a list of individual words; however, I’m struggling at how to convert between a TextIO.elem to a string. For example, if I write the following code it returns a TextIO.elem but I don’t know how to convert it to a string so that I can concat it with another string
TextIO.input1 inStream
TextIO.elemis just a synonym forchar, so you can use thestrfunction to convert it to a string. But as I replied to elsewhere, I suggest usingTextIO.inputAllto get a string right away.Here is a function that takes an instream and delivers all (remaining) words in it:
The type of this function is
TextIO.instream -> string list.