One more rewrite of TextIO. Here are the new numbers. M/s input1 25.8 scanStream 8.0 For scanStream, MLton doesn't flatten out the state, and so does a lot of allocation. Another round of flattening would catch it, but what we need is a better flattener.