Skip to content

Haskell Series

This sample shows a compact Haskell note. It lets readers change a numeric sequence and inspect the result that runs from a build-time WASI module in the browser.

  • Reactive Haskell inputs for sequence parameters.
  • Standard-library Haskell code with a lifted import.
  • Text output captured from putStrLn.

The cell computes scaled triangular numbers. Toggle the delta output to compare each term with the previous one.

Haskell + WASI

Explore a Haskell series

Cell actions
Cell inputs
import Data.List (intercalate)

let indexes = [1 .. count]
let values = map (\n -> multiplier * n * (n + 1) `div` 2) indexes
let deltas = zipWith (-) (drop 1 values) values

putStrLn (label ++ ": " ++ intercalate ", " (map show values))
putStrLn ("total = " ++ show (sum values))

if show_deltas
  then putStrLn ("deltas = " ++ intercalate ", " (map show deltas))
  else putStrLn "deltas hidden"

Waiting for the runtime to start.

Haskell cells are intended for deterministic examples that fit the standard library. Use them when a short functional transformation is clearer than a handwritten table of results.