Skip to content

jupyter / jupyterlite kernel for Haskell powered by WebAssembly

License

Notifications You must be signed in to change notification settings

jupyter-xeus/xeus-haskell

Repository files navigation

xeus-haskell

Build Status

xeus-haskell is a Jupyter kernel for haskell based on the native implementation of the Jupyter protocol xeus.

image

Quickstart

For native JupyterLab

# Install Pixi
# curl -fsSL https://pixi.sh/install.sh | sh

git clone https://github.com/jupyter-xeus/xeus-haskell
pushd xeus-haskell
pixi run -e default prebuild
pixi run -e default build
pixi run -e default install
pixi run -e default serve # JupyterLab is ready!

For webassembly JupyterLite

# Install Pixi
# curl -fsSL https://pixi.sh/install.sh | sh

git clone https://github.com/jupyter-xeus/xeus-haskell
pushd xeus-haskell
pixi install -e wasm-host
pixi run -e wasm-build prebuild
pixi run -e wasm-build build
pixi run -e wasm-build install
# pixi run -e wasm-build fix-emscripten-links # You may need this
pixi run -e wasm-build serve # JupyterLite is ready!

Start Jupyter Lite with your library (Experimental feature)

To use your libraries, you mount the local directory (for example, $PWD/example) to /usr/lib/haskell-packages/microhs. The directory structure is as follows:

/usr/lib/haskell-packages/microhs (local: $PWD/example)
|
+-Example
| |
| +-Hello.hs (`Example.Hello` module)
|
+-Math
| |
| +-Fibonacci.hs (`Math.Fibonacci` module)
|
.
.
.

The recipe is as follows:

pushd xeus-haskell
pixi install -e wasm-host
pixi run -e wasm-build prebuild
pixi run -e wasm-build build
pixi run -e wasm-build install
pixi shell -e wasm-build
pixi run -e wasm-build jupyter lite serve \
  --XeusAddon.prefix="$PWD/.envs/wasm-host" \
  --XeusAddon.mounts="$PWD/.envs/wasm-host/share/microhs:/share/microhs" \
  --XeusAddon.mounts="$PWD/example/Example:/usr/lib/haskell-packages/microhs/Example" \
  --contents notebooks/introduction_to_haskell.ipynb \

HTML Output (Experimental feature)

import XHaskell.Display

newtype HTMLString = HTMLString String
instance Display HTMLString where
  display (HTMLString html) = DisplayData {
      mimeType = "text/html",
      content  = html
  }
instance Display String where
  display str = DisplayData "text/plain"

putStr $ show (display (HTMLString "<p style=\"color: red\">foo</p>"))

Generate Jupyter Lite as a static webpage

You can generate Jupyter Lite as a static webpage with jupyter lite generate command.

pixi run -e wasm-build jupyter lite generate \
  --XeusAddon.prefix="$PWD/.envs/wasm-host" \
  --XeusAddon.mounts="$PWD/.envs/wasm-host/share/microhs:/share/microhs" \
  # --XeusAddon.mounts="$PWD/example:/usr/lib/haskell-packages/microhs" \
  --contents notebooks/introduction_to_haskell.ipynb \

Trying it online

To try out xeus-haskell interactively in your web browser, just click on the link:

Jupyterlite for Haskell

Features

xeus-haskell provides a rich interactive environment for Haskell:

  • Incremental Execution: State (definitions and types) is preserved across multiple cells.
  • Mixed Content Support: Support for cells containing both definitions and expressions (GHCi-style).
  • Shift+Tab Introspection: Quick access to type signatures and kinds for identifiers.
  • Tab Completion: Intelligent completion suggestions for Haskell identifiers.
  • Rich Display System: Integrated support for rendering HTML, LaTeX, and Markdown via the Display typeclass.
  • Cross-Platform: Works natively on Linux, macOS, Windows, and in the browser via WebAssembly (JupyterLite).

Dependencies

xeus-haskell depends on

Contributing

See CONTRIBUTING.md to know how to contribute and set up a development environment.

License

This software is licensed under the Apache Software License 2.0. See the LICENSE file for details.

About

jupyter / jupyterlite kernel for Haskell powered by WebAssembly

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •