Hakaru

An embedded probabilistic programming language for Haskell.

Installation

To install hakaru, just grab it from hackage

cabal update
cabal install hakaru

Simple Example

As an example, here is how we would infer the bias of a coin after observing how it landed when flipped 10 times.

import Control.Monad (replicateM)
import Data.Dynamic (toDyn)
import Language.Hakaru.Types
import Language.Hakaru.Distribution
import Language.Hakaru.Metropolis

heads = Just (toDyn (Discrete True))

prog :: Measure Double
prog = do
   bias <- unconditioned (beta 1 1)
   replicateM 10 $ conditioned (bern bias)
   return bias

sample prog (replicate 10 heads)

For a more involved tutorial, consider browsing this IHaskell notebook.