Package

purescript-hylograph-selection

Repository
afcondon/purescript-hylograph-selection
License
MIT AND ISC
Uploaded by
pacchettibotti
Published on
2026-02-04T18:42:55Z

Tree Builder Demo

Type-safe D3 selection and attribute library for PureScript.

Overview

A declarative, type-safe approach to D3.js visualization in PureScript. Instead of imperative D3 method chaining, you build a tree AST that describes your visualization, then interpret it to render.

Installation

spago install hylograph-selection

Key Concepts

HATS (Hylomorphic Abstract Tree Syntax)

Build visualizations as data structures using HATS:

import Hylograph.AST as A
import Hylograph.Expr.Friendly (attr, num, text)
import Hylograph.Internal.Selection.Types (ElementType(..))

myViz :: A.Tree Unit
myViz =
  A.named SVG "chart"
    [ attr "width" $ num 400.0
    , attr "height" $ num 300.0
    ]
    `A.withChild`
      A.elem Circle
        [ attr "cx" $ num 200.0
        , attr "cy" $ num 150.0
        , attr "r" $ num 50.0
        , attr "fill" $ text "steelblue"
        ]

Data Joins

D3-style enter/update/exit with type safety:

A.joinData "circles" "circle" myData $ \d ->
  A.elem Circle
    [ fnAttr "cx" (_.x)
    , fnAttr "cy" (_.y)
    , fnAttr "r" (_.radius)
    ]

Interpreters

  • D3 Interpreter - Renders to DOM via D3.js
  • English Interpreter - Describes the tree in plain English
  • Mermaid Interpreter - Generates Mermaid diagrams
  • SemiQuine Interpreter - Generates PureScript code

Modules

Core

  • Hylograph.AST - Tree AST types and constructors
  • Hylograph.HATS - HATS DSL helpers
  • Hylograph.Render - Rendering utilities

Expressions

  • Hylograph.Expr.Friendly - Attribute helpers (attr, cx, cy, fill, etc.)
  • Hylograph.Expr.Attr - Low-level attribute types
  • Hylograph.Expr.Sugar - Convenience functions

Interpreters

  • Hylograph.Interpreter.D3 - D3.js rendering
  • Hylograph.Interpreter.English - Plain English description
  • Hylograph.Interpreter.Mermaid - Mermaid diagram generation
  • Hylograph.Interpreter.SemiQuine - Code generation

Interactions

  • Hylograph.Interaction.Zoom - Zoom behavior
  • Hylograph.Interaction.Brush - Brush selection
  • Hylograph.Interaction.Pointer - Pointer events

Utilities

  • Hylograph.Scale - D3-style scales
  • Hylograph.Axis.Axis - Axis rendering
  • Hylograph.Transform - SVG transforms
  • Hylograph.Tooltip - Tooltip helpers

Part of Hylograph

  • hylograph-selection - D3 selection library (this package)
  • hylograph-graph - Graph data structures
  • hylograph-layout - Layout algorithms
  • hylograph-simulation - Force simulation

Uses tree-rose for rose tree data structures.

License

MIT

Modules
Data.DependencyGraph
Hylograph.AST
Hylograph.Axis.Axis
Hylograph.Brush
Hylograph.Brush.FFI
Hylograph.Brush.Types
Hylograph.Classify
Hylograph.Data.Graph
Hylograph.Data.Graph.Algorithms
Hylograph.Data.Node
Hylograph.Data.Tree
Hylograph.Expr.Animation
Hylograph.Expr.Attr
Hylograph.Expr.Datum
Hylograph.Expr.Expr
Hylograph.Expr.Friendly
Hylograph.Expr.Integration
Hylograph.Expr.Interpreter.CodeGen
Hylograph.Expr.Interpreter.Eval
Hylograph.Expr.Interpreter.Meta
Hylograph.Expr.Interpreter.PureSVG
Hylograph.Expr.Interpreter.SVG
Hylograph.Expr.Path
Hylograph.Expr.Path.Generators
Hylograph.Expr.Sugar
Hylograph.Expr.Units
Hylograph.HATS
Hylograph.HATS.Friendly
Hylograph.HATS.InterpreterTick
Hylograph.HATS.Transitions
Hylograph.Interaction.Brush
Hylograph.Interaction.Coordinated
Hylograph.Interaction.Pointer
Hylograph.Interaction.Zoom
Hylograph.Internal.Attribute
Hylograph.Internal.Behavior.FFI
Hylograph.Internal.Behavior.Types
Hylograph.Internal.Capabilities.Selection
Hylograph.Internal.Capabilities.Transition
Hylograph.Internal.FFI
Hylograph.Internal.Selection.Join
Hylograph.Internal.Selection.Operations
Hylograph.Internal.Selection.Operations.Conversions
Hylograph.Internal.Selection.Operations.Helpers
Hylograph.Internal.Selection.Operations.Selection
Hylograph.Internal.Selection.Query
Hylograph.Internal.Selection.Types
Hylograph.Internal.Transition.FFI
Hylograph.Internal.Transition.Manager
Hylograph.Internal.Transition.Scene
Hylograph.Internal.Transition.Types
Hylograph.Internal.Types
Hylograph.Interpreter.D3
Hylograph.Interpreter.English
Hylograph.Interpreter.Mermaid
Hylograph.Interpreter.MetaAST
Hylograph.Interpreter.SemiQuine
Hylograph.Interpreter.SemiQuine.TreeToCode
Hylograph.Interpreter.SemiQuine.Types
Hylograph.Render
Hylograph.Scale
Hylograph.Scale.FP
Hylograph.Shape.Arc
Hylograph.Shape.Pie
Hylograph.Shape.Polygon
Hylograph.Tooltip
Hylograph.Transform
Hylograph.TreeDSL
Hylograph.TreeDSL.ShapeTree
Hylograph.Unified
Hylograph.Unified.Attribute
Hylograph.Unified.DataDSL
Hylograph.Unified.Display
Hylograph.Unified.Examples
Hylograph.Unified.Join
Hylograph.Unified.Sugar
Dependencies