xeus-haskell is a Jupyter kernel for haskell based on the native implementation of the
Jupyter protocol xeus.
# 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!
# 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!
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 \
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>"))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 \
To try out xeus-haskell interactively in your web browser, just click on the link:
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
Displaytypeclass. - Cross-Platform: Works natively on Linux, macOS, Windows, and in the browser via WebAssembly (JupyterLite).
xeus-haskell depends on
See CONTRIBUTING.md to know how to contribute and set up a development environment.
This software is licensed under the Apache Software License 2.0. See the LICENSE
file for details.