Skip to content
IHaskell image for Jupyter Docker Stacks
Dockerfile Python Makefile Shell
Branch: master
Clone or download
jamesdbrock Install ghc system-level
This image will work for `stack --docker`.
Latest commit ecfc991 Oct 16, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
hooks Init Apr 30, 2019
tests Properly configure Dockerhub test. May 10, 2019
.gitattributes Init Apr 30, 2019
.gitignore Init Apr 30, 2019
.travis.yml ghc build optimized binaries May 11, 2019
Dockerfile Install ghc system-level Oct 16, 2019
Makefile crosscompass dockerhub May 7, 2019 Install ghc system-level Oct 16, 2019
requirements-test.txt Init Apr 30, 2019
stack.config.yaml stack assume color terminal Oct 16, 2019
stack.stack.yaml stack.yaml lists extra-deps instead of packages Jun 16, 2019


Build Status launch Learn You a Haskell for Great Good!

A Community Jupyter Docker Stacks image. Provides the Jupyter IHaskell kernel in a Docker image which composes well with other Jupyter Docker Stacks. Images are published at DockerHub crosscompass/ihaskell-notebook.

docker run the latest image right now with the following shell command, then open http://localhost:8888?token=x to try out the Jupyter notebook. Your current working directory on your host computer will be mounted at Home / pwd in JupyterLab.

    docker run --rm \
      -p 8888:8888 \
      -v $PWD:/home/jovyan/pwd \
      --env JUPYTER_ENABLE_LAB=yes \
      --env JUPYTER_TOKEN=x \
      --name ihaskell_notebook \

This image includes:

To ensure that this image composes well with any authentication and storage configuration (for example SystemUserSpawner) or notebook directory structure, we try to avoid installing any binaries in the Docker image in /home/jovyan.

This image is made with JupyterLab in mind, but it works well for classic notebooks.

Example notebooks are collected together in the container at /home/jovyan/ihaskell_examples.


Some libraries for instances of IHaskell.Display are pre-installed in the JupyterLab container.

The installed libraries mostly come from mostly from IHaskell/ihaskell-display, and are installed if they appeared to be working at the time the JupyterLab Docker image was built. You can try to install the other IHaskell/ihaskell-display libraries, and they will be built from the /opt/IHaskell source in the container.

stack install ihaskell-diagrams

See the Stack global project /opt/stack/global-project/stack.yaml for information about the /opt/IHaskell source in the container.

You can see which libraries are installed by running ghc-pkg:

stack exec ghc-pkg -- list | grep ihaskell

Stack global project

The ihaskell executable, the ihaskell library, the ghc-parser library, and the ipython-kernel library are built and installed at the level of the Stack global project in /opt/stack/global-project.

This means that the ihaskell environment is available for all users anywhere for any PWD inside the Docker container. (The PWD of a notebook is the always the directory in which the notebook is saved.)

The Stack global project resolver is determined by the IHaskell project resolver, and all included Haskell libraries are built using that Stack resolver.

You can install libraries with stack install. For example, if you encounter a notebook error like:

<interactive>:1:1: error:
   Could not find module ‘Deque’
   Use -v to see a list of the files searched for.

Then you can install the missing package from the terminal in your container:

stack install deque

Or, in a notebook, you can use the GHCi-style shell commands:

:!stack install deque

And then restart your IHaskell kernel.

You can use this technique to create a list of package dependencies at the top of a notebook:

:!stack install deque
import Deque
Deque.head $ fromList [1,2,3]
Just 1

Sadly, this doesn't work quite as frictionlessly as we would like. The first time you run the notebook, the packages will be installed, but then the kernel not load them. You must restart the kernel to load the newly-installed packages.

Local Stack Projects

You can run a IHaskell .ipynb in a Stack project PWD which has a stack.yaml.

You should copy the the contents of the container's Stack global project /opt/stack/global-project/stack.yaml into the local project's stack.yaml. That will give you the same resolver as the global project IHaskell installation, and it will also allow you to install libraries from IHaskell and IHaskell/ihaskell-display.

After your stack.yaml is configured, run :! stack build and then restart your IHaskell kernel.

You can try to run a IHaskell .ipynb in a PWD with a stack.yaml that has a resolver different from the resolver in /opt/stack/global-project/stack.yaml, but that is Undefined Behavior, as we say in C++.

System GHC

The GHC version specified by the IHaskell Stack resolver is also installed in the container at the system level, that is, on the executable PATH.

Composition with Docker Stacks

Rebase the IHaskell Dockerfile on top of another Jupyter Docker Stack image, for example the scipy-notebook:

docker build --build-arg BASE_CONTAINER=jupyter/scipy-notebook --rm --force-rm -t ihaskell_scipy_notebook:latest .

References, Links, Credits

IHaskell on Hackage

IHaskell on Stackage

IHaskell Wiki with Exemplary IHaskell Notebooks

When Is Haskell More Useful Than R Or Python In Data Science? by Tikhon Jelvis

This Docker image was made at Cross Compass in Tokyo.

You can’t perform that action at this time.