Understand Plot's type safety and design patterns
masterPlot employs several Swift language features to ensure a safe and ergonomic developer experience:
- Phantom Types: Plot uses types as "markers" for the compiler to enforce type safety through generic constraints.
DocumentFormatand theContextof nodes, elements, or attributes are phantom types; they are never instantiated but serve to associate values with a specific context or format. - Lightweight API Design: The API minimizes external argument labels to reduce syntax noise, creating a clean, DSL-like experience.
- SwiftUI-like Component API: The
ComponentAPI leverages Result Builders and Property Wrappers to allow for a declarative syntax similar to SwiftUI.