Extract giant case block to top-level function

This is for readability.
Merge pull request #1049 from david-christiansen/ideslave-cleanup

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