Getting Started
From zero to a running visualization in five minutes.
Prerequisites
You need three tools:
| Tool | Purpose | Install |
|---|---|---|
| Node.js | JavaScript runtime (v18+) | brew install node or nodejs.org |
| PureScript | Compiler | npm install -g purescript |
| Spago | Build tool and package manager | npm install -g spago |
Verify your setup:
purs --version # 0.15.x
spago --version # 0.93.x or later
node --version # v18+
Try a Demo
The fastest way to see Hylograph in action is to browse the demos online, or clone the demos repo and build them locally:
The Hylographic Fold (recommended first)
A seven-chapter interactive guide to how Hylograph works: view it online.
Build something locally
The how-to projects are the ones to clone. Each is a standalone project that builds from the registry alone:
git clone https://github.com/afcondon/hylograph-howto.git
cd hylograph-howto/simple-webpage
spago bundle
# Open public/index.html in your browser
All demos
The demos covering graph algorithms, layout, music, simulation and more are in the demos repository. That repository depends on sibling checkouts of several libraries that are not yet published, so it does not build from a clone on its own; browse the demos online instead.
Libraries
| Package | Description | |
|---|---|---|
| hylograph-selection | Core: HATS tree construction, the DOM and English interpreters, scales, color schemes, coordinated highlighting, zoom, brush, pointer events. | demo |
| hylograph-simulation | Force simulation — n-body, collision, link forces, centring and six more. Since 1.0 there is no D3 in it: the forces are hylograph-forces, in PureScript, with an optional Rust/WASM kernel. |
demo |
| hylograph-forces | The force kernel under hylograph-simulation: d3-force's forces in PureScript, held to d3-force bit for bit, and six that d3 does not have. |
|
| hylograph-wasm-kernel | The optional Rust/WASM kernel for hylograph-simulation, carried inside the package: nothing to build or serve. |
|
| hylograph-simulation-halogen | Halogen subscription adapter: a simulation's events as a Halogen emitter. | |
| hylograph-layout | Layout algorithms in pure PureScript — tree and cluster layouts, pack, partition, treemap, edge bundling, Sankey, chord. | demo |
| hylograph-graph | Graph data structures and algorithms — shortest path, traversals, connected and biconnected components, topological sort. | demo |
| hylograph-music | Proof of concept: data to sound, with an audio interpreter for HATS trees. | demo |
| hylograph-canvas | Canvas 2D drawing of circles and lines, with zoom and pan. Not a HATS interpreter. | |
| hylograph-optics | Optics (lenses, traversals) over rose trees and graphs. | |
| hylograph-transitions | Transition and animation engine for smooth visual updates. | |
| sigil | Typographic rendering for PureScript type signatures (HTML + SVG). | demo |
| sigil-hats | Bridge from Sigil layout trees to HATS for declarative composition. | demo |
spago install hylograph-selection (or whichever package you need). A package set can lag a new release: to use a version newer than your set carries, name it under workspace.extraPackages in spago.yaml, for example hylograph-simulation: "1.1.0".
Your First Visualization
Create a new project and add hylograph-selection:
spago init
spago install hylograph-selection
In src/Main.purs:
module Main where
import Prelude
import Effect (Effect)
import Hylograph.HATS (Tree, ElementType(..), elem, forEach)
import Hylograph.HATS.Friendly as F
import Hylograph.HATS.InterpreterTick (rerender)
myViz :: Tree
myViz =
elem SVG [ F.viewBox 0.0 0.0 400.0 200.0, F.width 400.0, F.height 200.0 ]
[ forEach "dots" Circle
[ { x: 80.0, label: "A" }
, { x: 200.0, label: "B" }
, { x: 320.0, label: "C" }
]
_.label
\d ->
elem Circle
[ F.cx d.x, F.cy 100.0, F.r 30.0
, F.fill "#2563eb"
] []
]
main :: Effect Unit
main = void $ rerender "#app" myViz
Create an index.html with a <div id="app"></div>, bundle with spago bundle, and open it in a browser. Three blue circles.
From here, explore the interactive demo to understand how folds, composition, and interpreters work together.
