Working with Jupyter Kernels

Nextjournal already offers several Jupyter kernels in addition to native support for R, Python, Julia, Clojure, and Bash. A new experimental feature makes it easy to add new Jupyter runtimes.

Adding a Jupyter Runtime Language

Nextjournal already supports IPython, IJulia, and IRkernel. The team has recently added F#, Scala, Agda, Scheme, and Haskell Jupyter kernels as reusable environments.

  1. Run Nextjournal in experimental mode by appending ?experimental=1 to the end of your url and reloading the page.

  2. Click the + button between nodes and select Jupyter Runtime Language. For more information about working with the insert menu, see Adding Nodes.

  3. You will be taken to a special cell called Add a Jupyter runtime language. Select an environment from the list. You may be asked to also select which version of the language you prefer.

  4. Press Save & Add [Language] Code Cell where [Language] is the new Jupyter runtime environment.

  5. Click the + button between nodes and select Code Cell: [Language]. For more information about working with code cells, see Code Cells.

Showcase: IHaskell

import IHaskell.Display
html "<h1>I 💜 Haskell</h1>"
1.8s
Haskell

Kernel detection is done by searching for kernel specification files in usual system folders, the script we're using to find such files is a nextjournal notebook itself.

Adding a Jupyter Image Using Docker

We baked new default nextjournal environments for F#, Scala and Haskell but any Nextjournal environment with a kernel installed will do. You can for instance download an arbitrary Docker image via Import Docker Environment option in the insert menu. Let's try with the Calysto Scheme image:

Scheme
Download as Docker image from:
Copy
This image was imported from: calysto/calysto_scheme

Now add a new Jupyter Runtime Language node, select the Scheme environment, save and add a scheme cell:

(define filter-map
  (lambda (f pred? values)
    (if (null? values)
      '()
      (if (pred? (car values))
          (cons (f (car values)) (filter-map f pred? (cdr values)))
          (filter-map f pred? (cdr values))))))
(define-syntax collect
  [(collect ?exp for ?var in ?list if ?condition)
   (filter-map (lambda (?var) ?exp) (lambda (?var) ?condition) ?list)])
0.1s
Scheme
Scheme

After this step you can add new scheme cells as usual via insert menu (or command+shift with an existing cell focused).

(collect (* n n) for n in (range 1 5) if odd?)
0.1s
Scheme
Scheme
%latex x_1 = \dfrac{a}{b}
0.0s
Scheme
Scheme

Known Caveats

While we do support Jupyter rich display system (via MIME bundles) and IPyWidgets, we cannot install custom frontend extensions and in general we can't support the client-side of jupyter custom communication layer yet. We're happy to hear feedback from our users and to solve issues with specific kernels.

Runtimes (2)
Runtime Languages (2)