{"id":13484489,"url":"https://github.com/akabe/ocaml-jupyter","last_synced_at":"2025-12-28T06:08:24.409Z","repository":{"id":22556926,"uuid":"97241116","full_name":"akabe/ocaml-jupyter","owner":"akabe","description":"An OCaml kernel for Jupyter (IPython) notebook","archived":false,"fork":false,"pushed_at":"2024-01-25T21:07:30.000Z","size":1905,"stargazers_count":295,"open_issues_count":12,"forks_count":45,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-29T19:08:37.074Z","etag":null,"topics":["dataanalysis","datascience","functional-programming","jupyter","jupyter-kernels","jupyter-notebook","machine-learning","ocaml","ocaml-kernel","ocaml-repl"],"latest_commit_sha":null,"homepage":"https://akabe.github.io/ocaml-jupyter/","language":"OCaml","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/akabe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-14T14:15:05.000Z","updated_at":"2025-03-22T13:58:33.000Z","dependencies_parsed_at":"2024-05-02T15:11:24.615Z","dependency_job_id":"15fcac28-e43d-4510-b26f-e624204f142e","html_url":"https://github.com/akabe/ocaml-jupyter","commit_stats":{"total_commits":265,"total_committers":25,"mean_commits":10.6,"dds":0.4867924528301887,"last_synced_commit":"ed45f5f04f730dc6978559ef41b05d64fc509a75"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabe%2Focaml-jupyter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabe%2Focaml-jupyter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabe%2Focaml-jupyter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akabe%2Focaml-jupyter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akabe","download_url":"https://codeload.github.com/akabe/ocaml-jupyter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393574,"owners_count":20931813,"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":["dataanalysis","datascience","functional-programming","jupyter","jupyter-kernels","jupyter-notebook","machine-learning","ocaml","ocaml-kernel","ocaml-repl"],"created_at":"2024-07-31T17:01:25.139Z","updated_at":"2025-12-28T06:08:24.357Z","avatar_url":"https://github.com/akabe.png","language":"OCaml","funding_links":["https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=ff69b4\u0026link=https://github.com/sponsors/srz-zumix","https://github.com/sponsors/akabe"],"categories":["OCaml","Jupyter Kernels","Jupyter内核","Developer Tools","Jupyter Notebook"],"sub_categories":[],"readme":"# OCaml Jupyter\n\n[![Jupyter protocol][protocol-img]][protocol] [![License][license-img]][license] [![CI](https://github.com/akabe/ocaml-jupyter/actions/workflows/ci.yaml/badge.svg)](https://github.com/akabe/ocaml-jupyter/actions/workflows/ci.yaml) [![Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=ff69b4\u0026link=https://github.com/sponsors/srz-zumix\n)](https://github.com/sponsors/akabe)\n\n[license]:      https://github.com/akabe/ocaml-jupyter/blob/master/LICENSE\n[license-img]:  https://img.shields.io/badge/license-MIT-blue.svg\n[protocol]:     https://jupyter-client.readthedocs.io/en/stable/messaging.html\n[protocol-img]: https://img.shields.io/badge/Jupyter%20protocol-5.2-blue.svg\n[travis]:       https://travis-ci.org/akabe/ocaml-jupyter\n[travis-img]:   https://img.shields.io/travis/akabe/ocaml-jupyter/master.svg?label=travis\n[jupyter]:      https://jupyter.org/\n[opam]:         https://opam.ocaml.org/\n\nAn OCaml kernel for [Jupyter notebook][jupyter].\n\nThis provides an OCaml REPL with a great user interface such as markdown/HTML documentation, LaTeX formula by MathJax, and image embedding.\n\n![Screenshot](https://akabe.github.io/ocaml-jupyter/images/screenshot.png)\n\n## Getting started\n\nOCaml Jupyter requires the libraries zlib, libffi, libgmp, libzmq 5+. Type one of the following commands suitable for your environment.\n\n```shell\n# For Debian or Ubuntu:\nsudo apt-get install -y zlib1g-dev libffi-dev libgmp-dev libzmq5-dev\n# For REHL or CentOS:\nsudo yum install -y epel-release\nsudo yum install -y zlib-devel libffi-dev gmp-devel zeromq-devel\n# For Mac OS X:\nbrew install zlib libffi gmp zeromq\n```\n\nOCaml Jupyter can be installed by [OPAM][opam] as follows:\n\n``` shell\npip install jupyter\nopam install jupyter\ngrep topfind ~/.ocamlinit || echo '#use \"topfind\";;' \u003e\u003e ~/.ocamlinit  # For using '#require' directive\ngrep Topfind.log ~/.ocamlinit || echo 'Topfind.log:=ignore;;' \u003e\u003e ~/.ocamlinit  # Suppress logging of topfind (recommended but not necessary)\nocaml-jupyter-opam-genspec\njupyter kernelspec install [ --user ] --name \"ocaml-jupyter-$(opam var switch)\" \"$(opam var share)/jupyter\"\n```\n\nIf the last command fails due to permission, `--user` option or `sudo` is required. You can use `ocaml-jupyter` kernel by launching Jupyter notebook server:\n\n```shell\njupyter notebook\n```\n\n### Development version\n\n```shell\nopam pin add jupyter https://github.com/akabe/ocaml-jupyter.git\n```\n\n## Usage\n\n### Examples\n\n- [Introduction](https://github.com/akabe/ocaml-jupyter/blob/master/notebooks/introduction.ipynb):\n  a very simple example for use of OCaml Jupyter and sub-packages.\n- [Get a description of a word from DuckDuckGo API](https://github.com/akabe/ocaml-jupyter/blob/master/notebooks/word_description_from_DuckDuckGoAPI.ipynb):\n  request to DuckDuckGo API server by `cohttp.lwt`, and parse a response JSON by `yojson` and `ppx_yojson_conv`.\n\nIn addition, many examples (e.g, image processing, voice analysis, etc.) are available at\n[docker-ocaml-jupyter-datascience/notebooks](https://github.com/akabe/docker-ocaml-jupyter-datascience/tree/master/notebooks).\n\nThese examples are placed in the **public domain**, e.g., you can edit, copy, and re-distribute with no copyright messages.\n\n### Code completion\n\nOCaml Jupyter kernel supports [merlin](https://ocaml.github.io/merlin/)-based code completion. Candidates are shown by Tab key like\n\n![Code completion](https://akabe.github.io/ocaml-jupyter/images/completion.png)\n\nThe kernel uses [.merlin](https://github.com/ocaml/merlin/wiki/project-configuration) file at a notebook directory for completion.\n\n### Inspection\n\n_Inspection_ in Jupyter is also achieved by merlin. You can see documentation and type of an identifier by Shift+Tab key like\n\n![Inspection](https://akabe.github.io/ocaml-jupyter/images/inspect.png)\n\n### API documentation\n\nOCaml Jupyter includes some sub-packages:\n\n- [jupyter][jupyter-core] is a core library of OCaml Jupyter. This package is internally used. You don't need it directly.\n- [jupyter.notebook][jupyter-notebook] is a library to control Jupyter from OCaml REPL in notebooks. This provides dynamic generation of HTML/markdown, and image embedding.\n- [jupyter.comm][jupyter-comm] is a library for communication between OCaml notebooks and Jupyter/Web frontend.\n\n[jupyter-core]:       https://akabe.github.io/ocaml-jupyter/api/jupyter/\n[jupyter-notebook]:   https://akabe.github.io/ocaml-jupyter/api/jupyter/Jupyter_notebook/\n[jupyter-comm]:       https://akabe.github.io/ocaml-jupyter/api/jupyter/Jupyter_comm/\n\n### NBConvert\n\nOCaml notebooks can be converted to HTML, Markdown, LaTeX, `.ml` files, etc. using the `jupyter nbconvert` command.\nFor example, a `.ipynb` file is converted into a `.html` file as follows:\n\n```console\n$ jupyter nbconvert --to html notebooks/introduction.ipynb\n[NbConvertApp] Converting notebook notebooks/introduction.ipynb to html\n[NbConvertApp] Writing 463004 bytes to notebooks/introduction.html\n```\n\nFor exporting `.ml` files, we recommend [Jupyter-NBConvert-OCaml][Jupyter-NBConvert-OCaml]. It outputs `.ml` files with Markdown cells as comments. After installation of Jupyter-NBConvert-OCaml, you can use `--to ocaml` option to export a `.ml` file:\n\n```console\n$ jupyter nbconvert --to ocaml notebooks/introduction.ipynb\n[NbConvertApp] Converting notebook notebooks/introduction.ipynb to ocaml\n[NbConvertApp] Writing 2271 bytes to notebooks/introduction.ml\n```\n\n[Jupyter-NBConvert-OCaml]: https://github.com/Naereen/Jupyter-NBConvert-OCaml\n\n### Customize kernel parameters\n\n`ocaml-jupyter-opam-genspec` generates a configuration file like:\n\n```console\n$ cat \"$(opam var share)/jupyter/kernel.json\"\n{\n  \"display_name\": \"OCaml 4.08.1\",\n  \"language\": \"OCaml\",\n  \"argv\": [\n    \"/bin/sh\",\n    \"-c\",\n    \"eval $(opam env --switch=4.08.1) \u0026\u0026 /home/xxxx/.opam/4.08.1/bin/ocaml-jupyter-kernel \\\"$@\\\"\",\n    \"-init\", \"/home/xxxx/.ocamlinit\",\n    \"--merlin\", \"/home/xxxx/.opam/4.08.1/bin/ocamlmerlin\",\n    \"--verbosity\", \"app\",\n    \"--connection-file\", \"{connection_file}\"\n  ]\n}\n```\n\nSee `ocaml-jupyter-kernel --help` for details of command-line parameters in `argv`. After you edit the file, re-register the kernel:\n\n```shell\njupyter kernelspec install --name ocaml-jupyter \"$(opam var share)/jupyter\"\n```\n\n### Installation without OPAM\n\n`ocaml-jupyter-opam-genspec` depends on OPAM. If you use an other package manager, you need to write `kernel.json` by hand or use provided suitable way for registering a new kernel (e.g., [jupyter module](https://nixos.org/nixos/options.html#jupyter.kernels) on  [Nix](https://nixos.org/nix/)).\n\n## Running OCaml Jupyter on other environments\n\n### Binder\n\nOCaml Jupyter can be run on [Binder](https://www.mybinder.org).  Click\nthe button to get started:\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/edmcman/ocaml-jupyter-binder-environment/master?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252Fakabe%252Fdocker-ocaml-jupyter-datascience%26urlpath%3Dtree%252Fdocker-ocaml-jupyter-datascience%252Fnotebooks%252Fintroduction.ipynb%26branch%3Dmaster)\n\nFor more information, see this [repository](https://github.com/edmcman/ocaml-jupyter-binder-environment).\n\n### Google Colab\n\nOCaml Jupyter can be run on Google Colab. In order to do this you first have to run\n[this Python notebook](http://colab.research.google.com/github/akabe/ocaml-jupyter/blob/master/notebooks/install_ocaml_colab.ipynb)\nin your Colab instance. This will install the kernel and after that OCaml notebooks can be used on the same instance.\n\n## Sponsors\n\nIf you like this project, please support by becoming a sponsor via [GitHub Sponsors](https://github.com/sponsors/akabe).\n\n[\u003cimg width=200 src=\"https://raw.githubusercontent.com/akabe/ocaml-jupyter/gh-pages/images/sponsors/ahrefs.svg\"/\u003e](https://ahrefs.com/)\n\n## Related work\n\nMany Jupyter kernels for functional programming languages are available such as [IHaskell][ihaskell], [Jupyter Scala][jupyter-scala], and [Jupyter Rust][jupyter-rs]. [IOCaml][iocaml] is another practical OCaml kernel that inspires us, but it seems no longer maintained. OCaml Jupyter kernel differs from IOCaml in\n\n|                        | OCaml Jupyter | IOCaml v0.4.8 |\n| ---------------------- | ------------- | ------------- |\n| Jupyter protocol       | v5.2          | v3.2          |\n| OCaml PPX support      | Yes           | No            |\n| Session key support    | Yes           | No            |\n| Code completion        | Yes           | Yes           |\n| Introspection          | Yes           | Yes           |\n| User-defined messages  | Yes           | No            |\n| Stdin                  | Yes           | No            |\n\nAnother OCaml kernel [simple_jucaml][simple_jucaml] seems too simple to use in practice.\n[jupyter-kernel][jupyter-kernel] is a library to write OCaml kernels (*not a kernel*), but OCaml Jupyter kernel does not use this library.\n\n[ihaskell]:      https://github.com/gibiansky/IHaskell\n[jupyter-scala]: https://github.com/alexarchambault/jupyter-scala\n[jupyter-rs]:    https://github.com/pwoolcoc/jupyter-rs\n[iocaml]:        https://github.com/andrewray/iocaml\n[simple_jucaml]: https://github.com/KKostya/simple_jucaml\n[jupyter-kernel]:https://github.com/ocaml-jupyter/jupyter-kernel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakabe%2Focaml-jupyter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakabe%2Focaml-jupyter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakabe%2Focaml-jupyter/lists"}