As @CraigFe said, this conversation might be useful for other people looking to run OCaml for teaching or data-science in a Jupyter-based environments. Continuing the discussion from Suggestions from the OCaml Survey result where binder was mentioned, this looks like a neat way to lower the barrier to entry for programming in OCaml.
To add to what @mseri asked:
You can but it is a bit hacky. You first need to generate a blank ocaml.ipynb
locally and upload this to colabs, this will enable you to select Runtime > Change Runtime Type > Runtime Selection
to OCaml. Then you need to install OCaml, jupyter and add the kernel. This code block did the trick for me:
!add-apt-repository ppa:avsm/ppa && apt-get update && apt-get install opam m4 libgmp-dev
!opam init --disable-sandboxing -y
!opam install jupyter
!opam exec -- ocaml-jupyter-opam-genspec
!jupyter kernelspec install --user --name ocaml-jupyter "$(opam var share)/jupyter"
It takes quite a while and Iām not really going to recommend it, but it does work.
I also put together a few dockerfiles with the purpose of being used in jupyter environments for teaching. Also with an example of using nbgrader although I think this still needs some work (itās based on @kayceesrkās blog post). Are people using other setups for teaching OCaml in a classroom/university setting?
As a small aside, I started doing the survey analysis in OCaml, but found two issues:
- CSV loading with OWL was struggling (I think it struggled with the extra
,
in questions and also didnāt like multiple headers with the same name ā other libraries I think just add the column number to make it unique), I ended up using the csv library and then making the dataframe by hand. - The plotting library is good, but lacks the customisability that something like Matplotlib offers. I did start using the very good ocaml-matplotlib bindings but it all became a little too much effortā¦