Port to lens

This is nearly completely. Only two lines in `all_tests.hs` stand in the way of this being suitable for merge.