evancz/elm-repl — pull request #23 by maxsnew (2014-01-04 19:59:42+00:00)
Title: Basic Autocompletion

I've added some basic autocompletion to start. Right now it autocompletes variables you've specifically defined and it doesn't autocomplete when you're writing a String (for the most part, they don't handle escaping properly in the library).

In order to do that, I had to change the underlying monad for the repl from being just `IO` to carrying the State of the Repl (to access the completions) and I switched from using a Map to a Trie to get prefix lookup. I also have it skip lines that are entirely whitespace.

Other than that most changes are just plumbing with the monad.

The completion function can be improved, but this is a nice initial version. Some possible features:
1. Command completion when the user types in a `:`, i.e., `:h` will complete to `:help`
2. Import completion, i.e., if I've imported Dict, `Dict.e` would complete to `Dict.empty. This would require extending the State to carry information about identifiers imported from other modules.