Added complete support for the new type system syntax including: - concept: Base type declarations - sub_concept: Enum and record sub-type definitions - concept_comparison: Compile-time pattern matching with conditional guards Parser changes: - Added VariantPattern, FieldCondition, and Condition AST nodes - Implemented "is" keyword for pattern matching (e.g., "CupType is Glass or CupType is Plastic") - Added Value::Any variant to support universal type matching - Disambiguated enum-like vs record-like sub_concept syntax LSP updates: - Added Value::Any match arms across code_actions, completion, hover, inlay_hints, and semantic_tokens - Type inference and formatting support for Any values Example fixes: - Fixed syntax error in baker-family behaviors (missing closing brace in nested if) - Removed deprecated core_enums.sb file
Baker Family Example
A comprehensive example demonstrating Storybook v0.2.0 features through a realistic multi-character scenario.
Features Demonstrated
Resource Linking
- Templates with behaviors:
Bakertemplate specifiesBakingSkillsandCustomerService - Templates with schedules:
Bakertemplate usesBakerSchedule - Multi-level inheritance:
Baker→Worker→Persontemplate chain - Character inheritance: Characters automatically inherit behaviors and schedules from templates
Schedule Composition
- Schedule inheritance:
BakerSchedule extends WorkWeek - Override blocks: Modify inherited time blocks with
override work { ... } - Named blocks: All blocks have names for the override system
- Action references: Schedule blocks reference behavior trees via
action: BehaviorName - Recurrence patterns: Market day repeats
on Saturday
Behavior Trees
- Comprehensive behavior definitions for all activities
- Referenced from schedule blocks showing integration
- Hierarchical behaviors (sequences, selectors, repeaters)
File Structure
baker-family/
├── README.md # This file
├── schema/
│ └── templates.sb # Template definitions with resource linking
├── schedules/
│ └── work_schedules.sb # Composable schedules
├── behaviors/
│ └── baker_behaviors.sb # Behavior tree definitions
└── characters/
├── martha.sb # Master baker (uses Baker template)
├── john.sb # Pastry chef (uses Baker template)
└── emma.sb # Daughter (uses Child template)
Template Hierarchy
Person (behaviors: BasicNeeds, SocialInteraction)
└─> Worker (schedule: WorkWeek)
└─> Baker (behaviors: +BakingSkills, +CustomerService, schedule: BakerSchedule)
└─> Child (behaviors: PlayBehavior, LearnBehavior, no schedule)
Schedule Inheritance
WorkWeek
├─ morning_prep (08:00-09:00)
├─ work (09:00-17:00)
└─ evening_rest (18:00-22:00)
BakerSchedule extends WorkWeek
├─ pre_dawn_prep (04:00-05:00) [NEW]
├─ work (05:00-13:00) [OVERRIDE] → action: BakingWork
├─ evening_rest (18:00-22:00) [INHERITED]
└─ recurrence MarketDay on Saturday
└─ market (06:00-14:00) → action: SellAtMarket
Key Integration Points
-
Martha (character) → inherits from Baker (template)
- Gets behaviors:
BakingSkills,CustomerService,BasicNeeds,SocialInteraction - Gets schedule:
BakerSchedule(which extendsWorkWeek)
- Gets behaviors:
-
BakerSchedule (schedule) → references BakingWork (behavior)
action: BakingWorkin the work block- Creates link between scheduling and behavior systems
-
Template chain → cascading resource inheritance
BakerincludesWorkerincludesPerson- All behaviors and schedules flow down the hierarchy
Usage
This example shows how to:
- Build reusable templates with attached behaviors and schedules
- Create character hierarchies representing different roles
- Compose schedules through inheritance and overrides
- Link schedules to behaviors through action references
- Model realistic daily routines with time-of-day variations
- Handle special events (market days) with recurrence patterns
Narrative Implications
The Baker family example demonstrates:
- Daily rhythms: Early morning routine for bakers vs. normal schedule for child
- Weekly patterns: Special market day on Saturdays
- Role-based behaviors: Bakers have different skill sets than children
- Family dynamics: Multiple characters with interrelated but distinct routines
- Business operations: Work schedule tied to specific behaviors (baking, selling)
This is the kind of rich, time-based character modeling that makes Storybook ideal for narrative simulations and game design.