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.

/cc @etorreborre @charleso for review. This is roughly what I would like to replace most usages of Writer from  `Aws` with and also the IOAction log function. 
`filter` perhaps? /whatever