Add a trace data structure for mixed mode logging.

The general idea is that this can be used in Writer mode
for pure computations, and in IO mode for effectful
computations. Lifting between Writer and IO should
flush to disk.

This should replace bespoke cases of passing around logger
function, and the incorrect usage of Writer for debugging
messages.