Refactor

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Cabalify

Signed-off-by: Edward Z. Yang <ezyang@mit.edu>