Module

Hylograph.Config.Force

Package
purescript-hylograph-simulation
Repository
afcondon/purescript-hylograph-simulation

Force Configuration Module

This module defines immutable force configurations that are separate from the mutable d3-force JavaScript handles. This separation allows for:

  • Predictable scene transitions
  • Easy parameter resets
  • Better type safety
  • Improved debuggability

Key types:

  • ForceConfig: Complete force specification (type, name, params, filter)
  • ForceParams: Type-specific parameters (ManyBody, Collide, etc.)
  • AttrValue: Parameter values (static or function-based)

#Label Source

type Label = String

#AttrValue Source

data AttrValue a

An attribute value can be:

  • Static: a constant value for all nodes
  • Dynamic: computed per node
  • DynamicIndexed: computed per node with index

Constructors

Instances

#ForceFilter Source

data ForceFilter

Force filter - applies force only to nodes matching predicate e.g., "tree parents only", "packages only", "modules only"

Constructors

Instances

#ForceType Source

#ForceParams Source

data ForceParams

Type-specific force parameters Each force type has its own set of valid parameters

Constructors

Instances

#ForceConfig Source

newtype ForceConfig

Complete force configuration This is pure data with no JavaScript references

Constructors

Instances

#manyBodyForce Source

manyBodyForce :: Label -> ForceConfig

Create a many-body force with default parameters Default: repulsive force (negative strength)

#centerForce Source

centerForce :: Label -> ForceConfig

Create a centering force with default parameters

#collideForce Source

collideForce :: Label -> AttrValue Number -> ForceConfig

Create a collision force with default parameters Note: typically you want to provide a custom radius function

#forceX Source

forceX :: Label -> AttrValue Number -> ForceConfig

Create an X-positioning force with default parameters

#forceY Source

forceY :: Label -> AttrValue Number -> ForceConfig

Create a Y-positioning force with default parameters

#radialForce Source

radialForce :: Label -> Number -> ForceConfig

Create a radial force with default parameters

#linkForce Source

linkForce :: Label -> ForceConfig

Create a link force with default parameters

#updateParams Source

updateParams :: ForceConfig -> ForceParams -> ForceConfig

Update a force's parameters Provides a type-safe way to modify parameters

#withFilter Source

withFilter :: ForceConfig -> ForceFilter -> ForceConfig

Add or update a filter on a force

#withoutFilter Source

withoutFilter :: ForceConfig -> ForceConfig

Remove filter from a force

#withStrength Source

withStrength :: Number -> ForceConfig -> ForceConfig

Update strength parameter (works for forces that have strength)

#withRadius Source

withRadius :: AttrValue Number -> ForceConfig -> ForceConfig

Update radius parameter (works for Collide and Radial forces)

#withDistance Source

withDistance :: Number -> ForceConfig -> ForceConfig

Update distance parameter (Link force only)