Module

Hylograph.Internal.Selection.Types

Package
purescript-hylograph-selection
Repository
afcondon/purescript-hylograph-selection

Internal: Selection type and phantom state types.

Defines the core Selection type with phantom type parameters that track:

  • state: What operations are legal (SEmpty, SBoundOwns, SBoundInherits, SPending, SExiting)
  • parent: The parent element type
  • datum: The data type bound to each element

This enables compile-time enforcement of valid selection operation sequences, preventing runtime errors from invalid D3-style operations.

Internal module - use Hylograph.Selection for the public API.

#ElementType Source

data ElementType

Element types organized by rendering context

This ADT makes the distinction between SVG and HTML elements explicit, allowing the type system to guide proper namespace handling.

Constructors

Instances

#JoinResult Source

data JoinResult :: forall k. (Type -> Type -> k -> Type) -> Type -> k -> Typedata JoinResult sel parent datum

Result of a data join operation

The join splits data and elements into three disjoint sets:

  • enter: new data that needs elements created
  • update: existing elements that should be updated
  • exit: old elements that should be removed

Note the type signatures enforce correct usage:

  • enter is SPending (needs append)
  • update is SBoundOwns (owns data, can be modified)
  • exit is SExiting (should be removed) Polymorphic join result that works with any selection type wrapper This allows interpreters to use their own selection types (e.g., D3v2Selection_)

Constructors

#RenderContext Source

data RenderContext

Output context for rendering Determines which namespace to use when creating elements

Constructors

Instances

#SBoundInherits Source

#SBoundOwns Source

#SEmpty Source

data SEmpty

Phantom types representing selection states

These are uninhabited types used only at the type level to track what operations are legal on a selection.

#SExiting Source

#SPending Source

#Selection Source

newtype Selection (state :: Type) (parent :: Type) (datum :: Type)

A type-safe D3-style selection

The phantom type parameter state tracks what operations are legal:

  • SEmpty selections can receive data via join
  • SBoundOwns selections own their data binding, can be updated
  • SBoundInherits selections inherit parent's data, can be updated
  • SPending selections need elements appended
  • SExiting selections should be removed

The parent type parameter tracks the parent element type. The datum type parameter is the data bound to each element.

Examples:

svg :: Selection SEmpty Element Unit
circles :: Selection SBoundOwnsOwns Element Number
labels :: Selection SBoundOwnsInherits Element Number  -- inherits from circles
entering :: Selection SPending SVGElement Number
leaving :: Selection SExiting SVGElement Number

Constructors

Instances

  • Functor (Selection state parent)

    Functor instance for Selection

    Allows transforming the bound data without touching the DOM. This is pure - no effects, just data transformation.

    Examples:

    -- Transform numeric data
    doubled :: Selection SBoundOwnsOwns Element Int
    doubled = map (_ * 2) numbers
    
    -- Extract fields from records
    ages :: Selection SBoundOwnsOwns Element Int
    ages = map _.age people
    

#SelectionImpl Source

data SelectionImpl :: forall k. k -> Type -> Typedata SelectionImpl parent datum

Internal implementation of selections (not exported to users)

This ADT ensures that each state has exactly the data it needs:

  • EmptySelection: parent elements to bind data to
  • BoundSelection: elements with their bound data
  • PendingSelection: data waiting for elements
  • ExitingSelection: elements to be removed

Constructors

#elementContext Source

elementContext :: ElementType -> RenderContext

Determine which rendering context an element belongs to

#mkBoundSelection Source

mkBoundSelection :: forall parent datum. Array Element -> Array datum -> Maybe (Array Int) -> Document -> Selection SBoundOwns parent datum

Smart constructor for creating bound selections

Used internally to create selections with data bound to elements.

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