It’s nice that I had to remove some parts of my old list because they’ve since been implemented! In particular, the :list command was added with the GHCi debugger; GHCi now does multiline blocks with :{ and :}, and one of my requests for a better error message seems to no longer be an issue. This is nice to see!

The first request is for GHCi to continue doing its best to load a module when something goes wrong. Instead of punting entirely, it could still put those bits in scope that work correctly, and just report the errors on the bits that don’t work. This should probably only work for the open module (the one with an asterisk by it in the prompt.)

Going further in this direction, the behavior of the first ‘:t foo’ suggests that GHCi may be able to report guess (possibly incorrect) at piecing together the rest of the file in the event of errors. Here, callDatabase is not in scope, so type checking and inference can’t possible proceed correctly. However, type checking and inference can still proceed speculatively, by assuming callDatabase :: forall a. a! A warning is needed, of course, since the given type will likely be insufficiently specific once callDatabase is brought into scope.

The next two lines record what happens to callDatabase (you know, that symbol that wasn’t in scope). Basically, it’s treated as a bottom (i.e., undefined) value, so if it’s forced, then you get an exception. If it’s not forced, you can still use foo.

The :list command now exists for symbols or single lines. I still think a line range is a reasonable idea.

The next few lines show me interactively fixing the errors in MyFile.hs and using a made-up command “:recompile” to try to rebuild the currently loaded source file, except with currently defined symbols from the command line added to the top-level scope to replace those from the file where relevant. With that done, I can now ask for the type of foo, and get the true type, which is less general than the guess from earlier.

Next, I define a data type and an instance on the command line. I’d like to be able to define classes as well. These may not even need to be GHCi-specific enhancements to Haskell. Local instance declarations, for example, are already suggested (with restrictions would be needed to preserve principal types and coherence) by Oleg in the now-famous functional pearl on implicit configurations. Their use within GHCi is another potential motivating example.

The last bit I threw in is something I’ve found myself wanting far more often than I’d expect: a way to ask GHCi for the type of an expression in context. So while 6 has type Num a => a as expected, if taken in the given context, it turns out to have the more restricted type Fractional a => a, because of the upcoming division. I chose {{ and }} as markers in the unverified belief that at least “{{” can never occur in legal Haskell code, so they clearly form a subexpression marker instead of actual code.

Most of these are bigger projects, perhaps, than GSoC gives time for… or at a minimum, would need an applicant already familiar with GHC. But they sure would be convenient.