Getting started

Simple example

Minimal examples · How LazyPPL works

Choose a route

In your browser

LazyPPL is a Haskell library for Bayesian probabilistic programming.

Try LazyPPL in your browser

In Codespaces

Codespaces needs a GitHub account and opens the project in VS Code with GHC and Cabal already installed.

Open in GitHub Codespaces

Install locally on Ubuntu 24.04

System libraries

On Ubuntu, you can install the system libraries and the build tools as an administrator with

Shell
sudo apt-get update
sudo apt-get install -y --no-install-recommends build-essential ca-certificates curl git xz-utils libgmp-dev libtinfo-dev libffi-dev

GHCup and Cabal

The system uses Haskell Cabal. You need to install GHCup first, then GHC and Cabal, in your regular user account.

Shell
curl --proto "=https" --tlsv1.2 -sSf https://get-ghcup.haskell.org | env BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_MINIMAL=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=0 sh
source "$HOME/.ghcup/env"
ghcup install ghc 9.14.1
ghcup set ghc 9.14.1
ghcup install cabal 3.18.2.0
ghcup set cabal 3.18.2.0

Get LazyPPL

Shell
git clone https://github.com/lazyppl-team/lazyppl.git lazyppl

Open a terminal in the cloned lazyppl directory. Select the source revision used by these examples:

Shell
source "$HOME/.ghcup/env"
git switch --detach 859ee06149d0866068fd9e20e02e7f9efa7a4ccc
cabal update

Cabal uses GHC 9.14.1 installed above.

Run the first example

To explore with GHCi, type

Shell
cabal repl lib:lazyppl-examples

This takes some time (about two minutes on two vCPUs) if it is your first time ever using Cabal. To explore with GHCi again, type the same command (a later load took about one second).

To run, type the following at the GHCi prompt

Haskell
:module + MinimalDemo
runPoissonSim

This printed the following in one run (the example draws 10,000 samples, so other runs give slightly different numbers).

Text
k   poisson(k)
--  ----------
0   0.3678
1   0.3685
2   0.1804
3   6.48e-2
4   1.4e-2
5   3.6e-3
6   8.0e-4
7   1.0e-4

To leave GHCi, type

Text
:quit

Read the MinimalDemo example

Build the package

To build, type

Shell
cabal build

Other operating systems

For other operating systems, see the GHCup and Cabal installation guides.

GHCup installation guide · Cabal installation guide

On this page