[Syntax] Modules and imports (Recipes as Code) #9

Open
opened 2026-07-17 23:07:58 +02:00 by abiwab · 0 comments
abiwab commented 2026-07-17 23:07:58 +02:00 (Migrated from codeberg.org)

Context

Allowing the import of a Gram recipe inside another recipe is the missing link in the "Recipes as code" vision. It unlocks the creation of a packaged and versioned standard library (stocks, base doughs, mother sauces etc.).

Open Questions & Architecture Design

  • Declaration: Should imports be declared in the frontmatter (e.g., uses: { pastry: './bases/pate-feuilletee.gram' } and then used as &pastry{500 g}) or directly in the recipe body? Or both?
  • Section Replacement: If a user wants to replace an entire section of a recipe with an imported one (e.g., swapping the pie dough section in a lemon pie recipe), how should the syntax handle this?
  • Frontmatter Merging: What happens to the metadata and frontmatter of the imported recipes? How are they merged or isolated?

Technical Challenges

The times, tools, and grocery lists of the imported module must aggregate correctly within the host recipe. This is a major undertaking that requires rethinking parts of the analyzer and compiler to handle module resolution.

### Context Allowing the import of a Gram recipe inside another recipe is the missing link in the "Recipes as code" vision. It unlocks the creation of a packaged and versioned standard library (stocks, base doughs, mother sauces etc.). ### Open Questions & Architecture Design - **Declaration:** Should imports be declared in the frontmatter (e.g., `uses: { pastry: './bases/pate-feuilletee.gram' }` and then used as `&pastry{500 g}`) or directly in the recipe body? Or both? - **Section Replacement:** If a user wants to replace an entire section of a recipe with an imported one (e.g., swapping the pie dough section in a lemon pie recipe), how should the syntax handle this? - **Frontmatter Merging:** What happens to the metadata and frontmatter of the imported recipes? How are they merged or isolated? ### Technical Challenges The times, tools, and grocery lists of the imported module must aggregate correctly within the host recipe. This is a major undertaking that requires rethinking parts of the analyzer and compiler to handle module resolution.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gram-lang/gram#9
No description provided.