{"id":13484329,"url":"https://github.com/IHaskell/ihaskell-notebook","last_synced_at":"2025-03-27T16:30:43.242Z","repository":{"id":62832127,"uuid":"184373027","full_name":"IHaskell/ihaskell-notebook","owner":"IHaskell","description":"IHaskell image for Jupyter Docker Stacks","archived":false,"fork":false,"pushed_at":"2023-05-20T07:44:56.000Z","size":95,"stargazers_count":78,"open_issues_count":14,"forks_count":9,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T18:42:32.490Z","etag":null,"topics":["haskell","jupyter"],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IHaskell.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-05-01T05:27:44.000Z","updated_at":"2024-10-10T04:02:28.000Z","dependencies_parsed_at":"2024-01-13T18:26:06.662Z","dependency_job_id":"5ae535f2-be69-4751-87eb-4dc2a1b6096f","html_url":"https://github.com/IHaskell/ihaskell-notebook","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IHaskell%2Fihaskell-notebook","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IHaskell%2Fihaskell-notebook/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IHaskell%2Fihaskell-notebook/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IHaskell%2Fihaskell-notebook/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IHaskell","download_url":"https://codeload.github.com/IHaskell/ihaskell-notebook/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245882223,"owners_count":20687853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["haskell","jupyter"],"created_at":"2024-07-31T17:01:22.630Z","updated_at":"2025-03-27T16:30:41.625Z","avatar_url":"https://github.com/IHaskell.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"# ihaskell-notebook\n\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/IHaskell/learn-you-a-haskell-notebook/master?urlpath=lab/tree/ihaskell_examples/ihaskell/IHaskell.ipynb)\n\nA [Community Jupyter Docker Stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#community-stacks) image. Provides the Jupyter [IHaskell](https://github.com/IHaskell/IHaskell) kernel in a Docker image which composes well with other Jupyter Docker Stacks. Docker images are [published on the Github container registry.](https://github.com/IHaskell/ihaskell-notebook/pkgs/container/ihaskell-notebook)\n\n`docker run` the latest image right now with the following shell command, then open [http://localhost:8888](http://localhost:8888) to try out the Jupyter notebook. Your current working directory on your host computer will be mounted at __Home / pwd__ in JupyterLab.\n\n```bash\ndocker run --rm -p 8888:8888 -v $PWD:/home/jovyan/pwd --name ihaskell_notebook ghcr.io/ihaskell/ihaskell-notebook:master jupyter lab --ServerApp.token=''\n```\n\nOr with `podman`:\n\n```bash\npodman run --privileged --userns=keep-id --rm -p 8888:8888 -v $PWD:/home/jovyan/pwd --name ihaskell_notebook ghcr.io/ihaskell/ihaskell-notebook:master jupyter lab --ServerApp.token=''\n```\n\n## Image structure\n\nThis image includes:\n\n* [__JupyterLab 3__](https://jupyterlab.readthedocs.io/en/stable/)\n* [__IHaskell__](https://github.com/IHaskell/IHaskell) Jupyter kernel\n* [__jupyterlab-ihaskell__](https://github.com/IHaskell/IHaskell/tree/master/jupyterlab-ihaskell) JupyterLab extension for Haskell syntax highlighting in notebooks\n* Haskell libraries for instances of [IHaskell.Display](https://www.stackage.org/haddock/lts-12.26/ihaskell-0.9.1.0/IHaskell-Display.html)\n  * __ihaskell-aeson__ for [Aeson](http://hackage.haskell.org/package/aeson) JSON display\n  * __ihaskell-blaze__ for [Blaze](http://hackage.haskell.org/package/blaze-html) HTML display\n  * __ihaskell-gnuplot__ for [gnuplot](http://www.gnuplot.info/) graphing utility\n  * __ihaskell-juicypixels__ for [JuicyPixels](http://hackage.haskell.org/package/JuicyPixels) image display\n  * __ihaskell-plot__ for [plots](https://hackage.haskell.org/package/plots) diagrams-based plotting library\n  * __ihaskell-graphviz__ for [Graphviz](https://www.graphviz.org/) graph visualization\n  * __ihaskell-diagrams__ for [diagrams](https://archives.haskell.org/projects.haskell.org/diagrams/) language for creating vector graphics\n  * __ihaskell-charts__ for [Chart](https://github.com/timbod7/haskell-chart/wiki) rendering 2D charts\n  * __ihaskell-hatex__ for [HaTeX](http://daniel-diaz.github.io/projects/hatex/hatex-guide.html) LaTeX\n  * __ihaskell-widgets__ for [Widgets](https://github.com/IHaskell/IHaskell/tree/master/ihaskell-display/ihaskell-widgets) interactive user-interface controls\n  * [__DougBurke/ihaskell-hvega__](https://github.com/DougBurke/hvega) for [Vega/Vega-Lite rendering, natively supported by JupyterLab](https://jupyterlab.readthedocs.io/en/stable/user/file_formats.html#vega-lite)\n* [__Haskell Stack__](https://docs.haskellstack.org/en/stable/README/) package manager, with [Glasgow Haskell Compiler](https://www.haskell.org/ghc/).\n\nThe image is configured with the [common features of Jupyter Docker Stacks](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/common.html).\n\nTo ensure that this image composes well with any authentication and storage configuration\n(for example [SystemUserSpawner](https://github.com/jupyterhub/dockerspawner#systemuserspawner))\nor notebook directory structure, we try to avoid installing anything in the Docker image in `/home/jovyan`.\n\nThis image is made with JupyterLab in mind, but it works well for classic notebooks.\n\nExample notebooks are collected together in the container at `/home/jovyan/ihaskell_examples`.\n\n## `IHaskell.Display`\n\nSome libraries for instances of [`IHaskell.Display`](https://www.stackage.org/haddock/lts-12.26/ihaskell-0.9.1.0/IHaskell-Display.html) are pre-installed in the JupyterLab container.\n\nThe installed libraries mostly come from  mostly from [`IHaskell/ihaskell-display`](https://github.com/gibiansky/IHaskell/tree/master/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.\n\n```bash\nstack build ihaskell-magic\n```\n\nSee the Stack *global project* `/opt/stack/global-project/stack.yaml` for information about the `/opt/IHaskell` source in the container.\n\nYou can see which libraries are installed by running `ghc-pkg`:\n\n```bash\nstack exec ghc-pkg -- list | grep ihaskell\n    ihaskell-0.9.1.0\n    ihaskell-aeson-0.3.0.1\n    ihaskell-blaze-0.3.0.1\n    ihaskell-gnuplot-0.1.0.1\n    ihaskell-hvega-0.2.0.0\n    ihaskell-juicypixels-1.1.0.1\n    ...\n```\n\n## Stack *global project*\n\nThe `ihaskell` executable, the `ihaskell` library, the `ghc-parser` library,\nand the `ipython-kernel` library are built and installed at the level\nof the [Stack *global project*](https://docs.haskellstack.org/en/stable/yaml_configuration/#yaml-configuration) in `/opt/stack/global-project/stack.yaml`.\nThis design choice was discussed in [IHaskell issue #715](https://github.com/gibiansky/IHaskell/issues/715#issuecomment-338580095).\n\nThis means that the `ihaskell` environment is available for all users in any directory mounted in the\nDocker container, so you can __save and run `.ipynb` notebook files in any directory__, which is one of the main advantage of this IHaskell Docker image.\nThe present working directory (`PWD`) of a Jupyter notebook is the always the directory in which the notebook\nis saved.\n\nThe Stack *global project* `resolver`\nis determined by the IHaskell project `resolver`, and all included Haskell\nlibraries are built using that Stack `resolver`.\n\n### Installing Haskell packages\n\nYou can install packages with `stack build`. For example, if you encounter a notebook error for a missing `hmatrix` package,\n\n```\n\u003cinteractive\u003e:1:1: error:\n   Could not find module ‘Numeric.LinearAlgebra’\n   Use -v to see a list of the files searched for.\n```\n\nthen you can install the missing `hmatrix` package from the terminal in your container:\n\n```bash\nstack build hmatrix\n```\n\nOr, in a notebook, you can use the [GHCi-style shell commands](https://github.com/gibiansky/IHaskell/wiki#shelling-out):\n\n```\n:!stack build hmatrix\n```\n\nAnd then \u003ckbd\u003e⭮\u003c/kbd\u003e restart your IHaskell kernel.\n\nYou can use this technique to create a list of package dependencies at the top of a notebook:\n\n```\n:!stack build hmatrix\nimport Numeric.LinearAlgebra\nident 3\n```\n\n~~~\n(3\u003e\u003c3)\n [ 1.0, 0.0, 0.0\n , 0.0, 1.0, 0.0\n , 0.0, 0.0, 1.0 ]\n~~~\n\n#### Installing Haskell packages caveats\n\n1. You can only install packages from the\n   [Stackage](https://www.stackage.org/) snapshot from the Stack *global project*\n   [`/opt/stack/global-project/stack.yaml`](global-project.stack.yaml) `resolver`.\n2. The first time you run the notebook the packages will be installed, but\n   then the kernel will not load them. You must \u003ckbd\u003e⭮\u003c/kbd\u003e restart the\n   kernel to load the newly-installed packages.\n\n## Local project modules\n\nYou can add supporting modules of `.hs` files in the same directory where\nyour `.ipynb` notebook file is stored.\n\nIf you create a file `MyModule.hs` with the contents\n\n```haskell\nmodule MyModule where\nsupport x = x + x\n```\n\nThen you can use the `support` function in your `.ipynb` notebook like this\n\n```haskell\n:load MyModule\nimport MyModule (support)\n```\n\n## System GHC\n\nThe GHC version specified by the IHaskell Stack `resolver` is also installed\nin the container at the system level, that is, on the executable `PATH`.\n\n## Building and running the Dockerfile locally\n\n```\nmake build\nmake up\n```\n\nOpen http://localhost:8888/\n\n## Composition with Docker Stacks\n\nRebase the IHaskell `Dockerfile` on top of another Jupyter Docker Stack image, for example the\n[`scipy-notebook`](https://jupyter-docker-stacks.readthedocs.io/en/latest/using/selecting.html#jupyter-scipy-notebook):\n\n```\ndocker build --build-arg BASE_CONTAINER=jupyter/scipy-notebook --rm --force-rm -t ihaskell_scipy_notebook:latest .\n```\n\n\n## References, Links, Credits\n\n[IHaskell on Hackage](http://hackage.haskell.org/package/ihaskell)\n\n[IHaskell on Stackage](https://www.stackage.org/package/ihaskell/snapshots)\n\n[IHaskell Wiki with Exemplary IHaskell Notebooks](https://github.com/gibiansky/IHaskell/wiki)\n\n[Learn You a Haskell for Great Good, Jupyter adaptation](https://github.com/IHaskell/learn-you-a-haskell-notebook)\n\n[When Is Haskell More Useful Than R Or Python In Data Science?](https://www.quora.com/What-are-some-use-cases-for-which-it-would-be-beneficial-to-use-Haskell-rather-than-R-or-Python-in-data-science) by [Tikhon Jelvis](https://github.com/TikhonJelvis)\n\n[datahaskell.org](http://www.datahaskell.org/)\n\n[tweag/jupyterWith Jupyter Nix build](https://github.com/tweag/jupyterWith)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIHaskell%2Fihaskell-notebook","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FIHaskell%2Fihaskell-notebook","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FIHaskell%2Fihaskell-notebook/lists"}