Trouble with a the explode function SML

I have a .txt file that contains this:

d3%~19^fgh54 78nm,.j 1.2k~789bv

This is the code that I have:

fun parse(L) = 
 let
    val infile = TextIO.openIn(L) 
    fun read(infile) =
        if TextIO.endOfStream(infile) then " " else (valOf(TextIO.inputLine(infile))) ^ read(infile);
    fun split(S) = explode(S)
in
    split(read(infile))
end;

This is the output I get: [#"d",#"3",#"%",#"~",#"1",#"9",#"^",#"f",#"g",#"h",#"5",#"4",#" ",#"7",#"8", #"n",...] : char list

I cannot figure out why the explode will not turn the whole string it is given into a char list.


Solution 1:

The top-level printer in SML/NJ has limits for how much of data structures it prints.

You can adjust (among other things) the displayed length of lists and strings, and the depth of recursive structures with the Control.Print structure.

Example:

- Control.Print.printLength;
val it = ref 16 : int ref
- val stuff = [1,2,3,4,5,6,7,8,9,10];
val stuff = [1,2,3,4,5,6,7,8,9,10] : int list
- Control.Print.printLength := 4;
val it = () : unit
- stuff;
val it = [1,2,3,4,...] : int list
- Control.Print.printDepth;
val it = ref 5 : int ref
- val deep = [[[[[[[[]]]]]]]];
val deep = [[[[[#]]]]] : 'a list list list list list list list list
- Control.Print.printDepth := 10;
val it = () : unit
- deep;
val it = [[[[[[[[]]]]]]]] : 'a list list list list list list list list

If you want to see everything regardless of size, you need to define and use functions that print the way you like.