IHaskell/README.md

141 lines
5.1 KiB
Markdown
Raw Normal View History

2013-10-20 13:25:55 -07:00
IHaskell
2013-10-21 13:18:59 -07:00
===
IHaskell is an implementation of the [IPython](http://ipython.org) kernel protocol which allows you to use Haskell inside IPython frontends such as `qtconsole` and `notebook`.
2013-10-20 13:25:55 -07:00
2013-10-21 13:18:59 -07:00
The project works with the IPython shell:
![IPython Console](https://raw.github.com/gibiansky/IHaskell/master/images/ihaskell-console.png)
As well as the IPython browser-based notebook interface:
![IPython Notebook](https://raw.github.com/gibiansky/IHaskell/master/images/ihaskell-notebook.png)
Installation
===
Make sure you have IPython version 1.0 or higher. IHaskell will not work with older versions of IPython.
```bash
ipython --version # Should print 1.0.0 (or higher!)
```
2013-10-21 13:18:59 -07:00
Download the package from the Github repository:
```bash
git clone https://github.com/gibiansky/IHaskell
```
Install ZeroMQ:
```bash
2013-10-22 09:29:10 -07:00
sudo apt-get install libzmq3-dev # Ubuntu (Saucy only)
2013-10-21 13:18:59 -07:00
brew install zeromq # Macs with Homebrew
```
2013-10-22 09:29:10 -07:00
(For older versions of Ubuntu, you should be able to download the ZeroMQ3 source and install without much difficulty.)
2013-10-21 13:18:59 -07:00
Install Happy:
```bash
sudo apt-get install happy # Ubuntu
```
2013-10-21 13:18:59 -07:00
Install the package:
```bash
cd IHaskell;
cabal install;
```
2013-10-28 12:58:14 -07:00
If you do not have GHC or Cabal, you should be able to install both via the [Haskell Platform](http://www.haskell.org/platform/).
2013-10-21 13:18:59 -07:00
Create the IPython profile:
```bash
IHaskell setup
```
Run the notebook or console interface:
```bash
IHaskell notebook # Should open a browser window!
IHaskell console
```
There is a test notebook in the `IHaskell` directory.
Contributing
===
IHaskell is an extremely young project, and I'd love your help getting it to a stable and useful point. There's a lot to do, and if you'd like to contribute, feel free to get in touch with me via my email at andrew period gibiansky at gmail - although browsing the code should be enough to get you started, I'm more than happy to answer any questions myself.
Some ideas for improvements:
- Type annotations. When a statement is evaluated, the GHC API returns the names of all bound variables. It should be possible to take those names and find the types of the variables, and display them in a table via the `display_data` message.
- Implementing useful directives. Currently, support for GHCi-style ":"-initiated directives exist, but they do not do anything (and are instead just printed in green). Useful directives such as ":t" and ":i" and ":m [+-]" have yet to be implemented, and adding them would be a good way to get started with the codebase.
- Parsing and viewing of formats via `display_data` and HTML:
- `aeson` compatibility which displays JSON as syntax highlighted JSON code via HTML.
- Support for `repa` or `hmatrix` vectors and matrices being displayed.
- `A custom typeclass for displaying data types as HTML, similar to Show.
2013-10-21 13:34:59 -07:00
2013-10-21 13:47:20 -07:00
Take a look at the [developer notes](https://github.com/gibiansky/IHaskell/blob/master/README.md#developer-notes) as well - they are sparse but may be helpful.
2013-10-21 13:46:44 -07:00
2013-10-21 13:34:59 -07:00
Developer Notes
===
2013-10-21 13:46:44 -07:00
Before diving in, you should read the [brief description of IPython kernel architectures](http://andrew.gibiansky.com/blog/ipython/ipython-kernels/)
and read the [complete messaging protocol specification](http://ipython.org/ipython-doc/dev/development/messaging.html).
2013-10-21 14:29:15 -07:00
Skim the rather-lacking [Haddock documentation](http://gibiansky.github.io/IHaskell/IHaskell/).
2013-10-21 13:34:59 -07:00
Module Quickstart:
- `Main`: Argument parsing and basic messaging loop, using Haskell Chans to communicate with the ZeroMQ sockets.
- `IHaskell.Types`: All message type definitions.
- `IHaskell.Eval.Evaluate`: Wrapper around GHC API, exposing a single `evaluate` interface that runs a statement, declaration, import, or directive.
- `IHaskell.IPython`: Shell scripting wrapper using `Shelly` for the `notebook`, `setup`, and `console` commands.
- `IHaskell.Message.Parser`: Parsing messages received from IPython.
- `IHaskell.Message.UUID`: UUID generator and data structure.
- `IHaskell.Message.Writer`: `ToJSON` for Messages.
- `IHaskell.ZeroMQ`: Low-level ZeroMQ communication wrapper. `serveProfile` starts listening on all necessary sockets, and returns a `ZeroMQInterface` record. This record exposes reading and writing `Chan Message` messages for all the necessary sockets, so then the rest of the application can simply use that interface.
First steps:
- Fork and clone the repository.
- Build IHaskell.
2013-10-31 10:59:16 -04:00
```bash
cd <path-to-IHaskell>
cabal configure
cabal build
```
**Loading IHaskell into GHCi for testing:**
2013-10-31 10:59:16 -04:00
**Using cabal repl**
If you have the latest version of cabal (>v1.18.0), the simplest thing to do is
```bash
cd <path-to-IHaskell>
cabal repl
```
**Using GHCi directly**
Alternatively you can just call ghci with the appropriate options. You can find these in the IHaskell.cabal file.
```bash
ghci -XDoAndIfThenElse -XNoImplicitPrelude -XOverloadedStrings -package ghc -optP-include -optPdist/build/autogen/cabal_macros.h
```
or you can create a .ghci file in the top level directory, like so:
```bash
# IHaskell .ghci file
:set -package ghc
:set -package ghc-paths
:set -optP-include -optPdist/build/autogen/cabal_macros.h
:set -XDoAndIfThenElse -XNoImplicitPrelude -XOverloadedStrings
```
2013-10-31 10:59:16 -04:00