Refactor

This changes the convention of using `from*` functions in the file of the target IR to `to*` functions in the file of the source IR. A `Compiler` monad is introduced providing error handling and a unique name source, with proofs of the functor, applicative, and monad laws included as illustrative examples. The code is also tidied up in general a bit: in particular, `IsRec` is now just a synonym for `Bool`, eliminating some pattern matching.