Hylograph.Internal.Attribute
- Package
- purescript-hylograph-selection
- Repository
- afcondon/purescript-hylograph-selection
Core Attribute Types
Defines the fundamental types for SVG/HTML attributes in Hylograph. These types are the target of the finally-tagless expression system.
The Attribute ADT supports three patterns:
- Static: Same value for all elements
- Data-driven: Value computed from datum
- Indexed: Value computed from datum and index
Historical Note
This module previously contained a ToAttr typeclass with polymorphic
smart constructors (fill, cx, radius, etc.). That pattern was superseded
by the finally-tagless expression system which provides multi-interpretation
capabilities. See kept-for-historical-context/ToAttr-Pattern-Documentation.md.
#Attribute Source
data Attribute datumType-safe attribute with datum phantom type
Attributes can be:
- Static: Same value for all elements
- Data-driven: Value computed from datum (with source metadata)
- Indexed: Value computed from datum and index (with source metadata)
The phantom type datum ensures attributes are only applied
to selections with matching data types.
The AttrSource field enables interpreters to inspect attribute origins
without evaluating the functions.
Constructors
StaticAttr AttributeName AttributeValueDataAttr AttributeName AttrSource (datum -> AttributeValue)IndexedAttr AttributeName AttrSource (datum -> Int -> AttributeValue)AnimatedAttr { config :: AnimationConfig, fromValue :: Maybe (AnimatedValue datum), name :: AttributeName, toValue :: AnimatedValue datum }AnimatedCompound { config :: AnimationConfig, fromValues :: Array (AnimatedValue datum), generator :: Array Number -> String, name :: AttributeName, toValues :: Array (AnimatedValue datum) }
Instances
Show (Attribute datum)Contravariant AttributeContravariant instance for Attribute
Attributes consume data (they're data sinks), making them naturally contravariant. This enables attribute reuse via
cmap:-- Define attribute for specific type radiusAttr :: Attribute Number radiusAttr = DataAttr (AttributeName "r") NumberValue -- Adapt to work with richer type type Circle = { radius :: Number, x :: Number, y :: Number } circleRadiusAttr :: Attribute Circle circleRadiusAttr = cmap _.radius radiusAttrThe key insight:
cmapcomposes the projection function with the attribute's data accessor, allowing attributes written for simple types to work with complex types via field selection.
#AttributeName Source
newtype AttributeNameAttribute names (SVG/HTML properties)
We use a newtype to prevent typos and enable IDE autocomplete. The String inside is the actual DOM attribute name.
Constructors
Instances
#AttributeValue Source
data AttributeValueAttribute values
We support the most common value types. The ADT ensures type safety when setting attributes.
Constructors
Instances
#AttrSource Source
data AttrSourceSource metadata for attributes
Describes where the attribute value comes from, enabling interpreters like MetaAST to show meaningful information about attribute bindings.
This is automatically captured when using the DSL (field, num, etc.)
but is UnknownSource for raw PureScript functions (escape hatches).
Constructors
Instances
#AnimatedValue Source
data AnimatedValue datumAnimated value specification
Describes where the animation value comes from:
- StaticAnimValue: Constant number
- DataAnimValue: Computed from datum
- IndexedAnimValue: Computed from datum and element index
Constructors
StaticAnimValue NumberDataAnimValue (datum -> Number)IndexedAnimValue (datum -> Int -> Number)
Instances
Show (AnimatedValue datum)
#AnimationConfig Source
type AnimationConfig = { delay :: Milliseconds, duration :: Milliseconds, easing :: EasingType }Configuration for a single animated attribute
Specifies timing, easing, and delay for the animation.
#EasingType Source
data EasingTypeEnumeration of easing types for animations
Note: This mirrors Hylograph.Transition.Easing.EasingType but is defined here to avoid circular dependencies. The Manager module will convert between them.
Constructors
LinearQuadInQuadOutQuadInOutCubicInCubicOutCubicInOutSinInSinOutSinInOutExpInExpOutExpInOutCircleInCircleOutCircleInOutBackInBackOutBackInOutElasticInElasticOutElasticInOutBounceInBounceOutBounceInOut
Instances
#Milliseconds Source
type Milliseconds = NumberTime in milliseconds for animation configuration
#defaultAnimationConfig Source
defaultAnimationConfig :: AnimationConfigDefault animation configuration: 300ms, QuadOut, no delay
- 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
Animated compound attribute for paths and other generated strings
Animates multiple numeric values and calls a generator function to produce the final string value. Used for:
The generator receives interpolated values in the same order as fromValues/toValues.