Public Repository

Last pushed: 4 months ago
Short Description
Playground for Haskell
Full Description

Playground for Haskell

Based on "haskell:8.0.2" (starting with "v4"/"devex"; "v3" and below are based on "haskell:7.10.3") this images does two additional steps:

  1. Provided some (very basic) samples in the "/home/samples" directory
  2. Expose the "/home/playground" directory to be used as external scripts directory (when e.g. "-v $PWD/scripts:/home/playground" is used)

Hence this image can be used to provide a ghci (Haskell compiler) to compile and execute the local edited Haskell files.
To do this start a container and add the local e.g. scripts directory as volume:
docker run -it -v $PWD/scripts:/home/playground --rm mibo/pg-haskell /bin/bash

Locally the Haskell files can be edited in the scripts directory and executed in the container via e.g. ghci playground/sample.hs.
If the file is edited and updated locally it can be easily reloaded in ghci via :reload.

Run a sample script

To run one of the provided sample scripts follow below steps:

  1. Start Docker with bash (docker run -it --rm mibo/pg-haskell:devex /bin/bash)
  2. Start the GHCi Shell with the sample script (ghci /home/samples/0_max_sample.hs) (<- in the Docker container)
  3. Run maxpm [42, 4711, 19, 3, 81, 1972] to get result of 4711 (<- in the Docker container)

The result of all above commands should look like:

docker$ docker run -it --rm mibo/pg-haskell:devex /bin/bash
root@b0f44b36f76a:/home# ghci /home/samples/0_max_sample.hs
GHCi, version 7.10.3:  :? for help
[1 of 1] Compiling Main             ( /home/samples/0_max_sample.hs, interpreted )
Ok, modules loaded: Main.
*Main> maxpm [42, 4711, 19, 3, 81, 1972]

When finished the GHCi shell can be exited with entering :quit (within the GHCi) and to exit the running Docker container enter exit (within the Linux OS).

Docker Pull Command