Module

Hylograph.Expr.Units

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

Type-Safe CSS Units

Phantom types for CSS units, enabling type-safe unit handling while allowing interpreters to render appropriately.

Key insight: Each interpreter renders units differently:

  • Eval: strips units, returns raw Number (for D3 SVG which uses unitless)
  • CodeGen: preserves unit constructor calls (px 10.0)
  • SVG: renders with CSS suffix "10px" or unitless for SVG attributes

#Pixels Source

data Pixels

#Em Source

data Em

#Rem Source

data Rem

#Percent Source

data Percent

#ViewportWidth Source

#ViewportHeight Source

#Unitless Source

#UnitExpr Source

class UnitExpr :: (Type -> Type) -> Constraintclass UnitExpr repr  where

Unit expressions - create values with specific units

These constructors are interpreted differently:

  • Eval: px 10.010.0 (raw number for D3)
  • CodeGen: px 10.0"(px 10.0)" (source code)
  • SVG: px 10.0"10px" or "10" depending on context

Members

#UnitArith Source

class UnitArith :: forall k. (k -> Type) -> Constraintclass UnitArith repr  where

Unit-safe arithmetic

You can only add/subtract values with the same unit type. Scaling (multiply by unitless) preserves the unit.

Members

  • addU :: forall u. repr u -> repr u -> repr u

    Add two values with the same unit

  • subU :: forall u. repr u -> repr u -> repr u

    Subtract two values with the same unit

  • scaleU :: forall u. repr u -> Number -> repr u

    Scale a unit value by a unitless factor

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