Extract giant case block to top-level function in IDESlave in REPL.hs

This is for readability.