Ticket #1609 (new proposed-project)
GHCi in the web browser
| Reported by: | apfelmus | Owned by: | apfelmus |
|---|---|---|---|
| Priority: | not yet rated | Keywords: | GHCi, interpreter, web |
| Cc: | apfelmus@… | Topic: | misc |
| Difficulty: | unknown | Mentor: | not-accepted |
Description
GHCi in the web browser
Imagine that you're drawing a picture in Haskell with the diagrams package. Wouldn't it be awesome if you could just enter the expression into GHCi and it would draw the picture right there, like this?
And what about entering a function of type Double -> Double in the interpreter and immediately seeing a graph of it?
The goal of this proposal is to create a Haskell interpreter that is capable of displaying images, animations and even interactive programs.
For maximum adoption and reuse, the GUI of the new interactive interpreter is to be implemented as a HTML page in the web browser. The GUI communicates with a server that is responsible for evaluating Haskell expressions.
Project Scope
This endeavor should emphasize modularity and reuse. The first step would be to create a small JavaScript? object that represents a Haskell interpreter and supports functions like GHCi.load(uri) or GHCi.eval(expr) and to implement corresponding server code. For maximum modularity, the server should load source files from a URI. Since we are now in a HTML page, the server can return values in the form of arbitrary images, animations, hyperlinks and so on.
Implementing this is not entirely straightforward, but most of the difficult problems have probably already been solved by prior work, like Chris Done's TryHaskell online interpreter and Péter Diviánszky's activehs online courses.
Building on these simple yet powerful basics, the view opens up to a wide range of possible applications:
- A replacement for the local GHCi, by running the server locally. Since the server can load from arbitrary URIs, this already allows us to code collaboratively with [Etherpad].
- Integration with source code editors and IDEs like TextMate. In particular, augment compilation error with hyperlinks that point back to the source file.
- Turn GHCi into an online service, using the SafeHaskell? extension.
- Implementation of a notebook model (like Mathematica) that goes beyond the linear command line model of the traditional GHCi.
- Integrate into documentation tools like Haddock or Brent Yorgey's diagrams user guide, so that explanations and API documentation can now be enhanced with live examples.
- Building a multiple user environment for use in teaching. A single interpreter session can be shared across different clients, be made read-only, and so on.
- Displaying interactive values. So far, the display is limited to static values, possibly animated with JavaScript?. But what about interactive values that communicate back with the server to evaluate more Haskell functions? Conal Elliott's tangible values are the right abstraction for this.
- ...
Of course, this list is just a taste of the possibilities and not everything can be implemented in one summer. Still, I'm sure that the end result will be fantastic and that the emphasis on modularity will enable the Haskell community to build more awesome things on top.
Interested Mentors
Heinrich Apfelmus


