README

Baba Yaga Tutorials

Welcome to the Baba Yaga tutorials! These tutorials will guide you through learning this functional programming language step by step.

Getting Started

Start with the Introduction tutorial to learn the basics, then follow the numbered sequence for a complete learning path.

Tutorial Sequence

🚀 Beginner Level

  1. 00_Introduction.md - Basic concepts, functions, and pattern matching
  2. 01_Function_Calls.md - Function calls without parentheses (juxtaposition)
  3. 02_Function_Composition.md - Function composition with via, compose, and pipe
  4. 03_Table_Operations.md - Working with tables and element-wise operations
  5. 04_Currying.md - Partial function application by default
  6. 05_Pattern_Matching.md - Pattern matching with when expressions
  7. 06_Immutable_Tables.md - Immutable table operations and functional programming
  8. 07_Function_References.md - Function references with @ symbol

🔧 Intermediate Level

  1. 08_Combinators.md - Understanding the combinator-based architecture
  2. 09_Expression_Based.md - Expression-based programming without explicit returns
  3. 10_Tables_Deep_Dive.md - Advanced table usage and data structures
  4. 11_Standard_Library.md - Overview of available functions and combinators
  5. 12_IO_Operations.md - Input/output operations and assertions
  6. 13_Error_Handling.md - Error handling patterns and validation

🎯 Advanced Level

  1. 14_Advanced_Combinators.md - Advanced combinator patterns and optimization
  2. 15_Integration_Patterns.md - External system integration and APIs
  3. 16_Best_Practices.md - Best practices and coding guidelines

Key Concepts Covered

  • Functional Programming: Pure functions, immutability, composition
  • Pattern Matching: when expressions for conditional logic
  • Tables: Immutable data structures with functional operations
  • Combinators: Higher-order functions for data transformation
  • IO Operations: Input/output, assertions, and event handling
  • Error Handling: Functional error patterns and validation
  • Integration: External system integration patterns
  • Best Practices: Operator spacing, syntax guidelines, and code organization

REPL Integration Documentation

For comprehensive integration patterns and harness architecture documentation, see the REPL Documentation which is generated directly from the REPL source code and contains extensive JSDoc comments about:

  • Architecture overview and TEA-inspired patterns
  • Harness integration examples
  • Adapter pattern implementation
  • State management and versioning
  • Error handling and recovery
  • Command routing strategies
  • Complete integration examples

Quick Reference

Essential Syntax

/* Function definition */
function_name : param1 param2 -> expression;

/* Function application */
function_name arg1 arg2;

/* Pattern matching */
when value is
  pattern1 then result1
  pattern2 then result2
  _ then default_result;

/* Table literals */
{key1: value1, key2: value2};

/* Function references */
map @function_name collection;

/* IO operations */
..out "Hello, World!";
..assert "test" 5 = 5;
..emit "event" data;
..listen "event" handler;

Best Practices

  • ✅ Use spaces around binary operators: 5 - 3, 5 + 3, 5 * 3
  • ✅ Unary minus works without parentheses: -5, f -5
  • ✅ Use parentheses for explicit grouping: (-5), (5 + 3) * 2
  • ✅ Follow functional conventions: Immutable data, pure functions
  • ✅ Keep functions focused: Single responsibility principle
  • ✅ Use descriptive names: Clear intent and purpose
  • ✅ Handle errors explicitly: Pattern matching over exceptions

Running Examples

To run examples from these tutorials:

  1. Create a .txt or .baba file with the example code
  2. Run: node lang.js your_file.txt

Example:

# Create test.txt with tutorial code
echo "result : 5 - 3;" > test.txt

# Run the example
node lang.js test.txt

File Extensions

Baba Yaga files should use either the .txt file extension, or the .baba extension.

Need Help?

Happy learning! 🚀