evalCommand (Statement stmt) = do
-- Capture stdout from the code we're running
(printed, result) <- capturedStatement stmt
case result of
RunOk boundNames ->
-- On success, just return the printed text
return [Display PlainText printed]
RunException exception -> do
-- On error, show the exception in red italics
return [Display MimeHtml $ makeError $ show exception]
Note the "on success" bit, which returns just [Display PlainText printed]. We can use the GHC API here to look at the types and values of any bound names, or potentially parse the stdout output, and then use those to generate DisplayData values that are more useful than just the printed plain text. This is where we can extend IHaskell greatly, and make it give us really pretty output. I have not figured out exactly how to use the GHC API to do all of this and how to make it modular, but that's the ultimate goal. (Hopefully, I can figure out some way such that if you install a package - say, "ihaskell-repa" - which includes some typeclass instances that we use for converting to DisplayData, IHaskell will automatically detect and use the installed package. This might involve even more GHC hackery and dynamic linking, though, but I think it should be possible.)
Hope this clarified things. Let me know if you have any more questions :)
-- Andrew