?? Babalawo

Static Analysis & Linting for Ifá-Lang

The Babalawo (Yoruba: "Father of Secrets") is Ifá-Lang's compile-time analyzer. It checks your code for errors, style issues, and potential bugs before runtime, providing wisdom-based suggestions drawn from Ifá divination traditions.

Quick Start

# Run linter on a file
ifa check main.ifa

# Run with all warnings enabled
ifa check --strict main.ifa

# Check entire project
ifa check .

Core Components

BabalawoConfig

Configuration for the linter. Controls which checks are enabled.

BabalawoConfig

// Default configuration
ayanmo config = BabalawoConfig.default();

// Custom configuration
ayanmo config = BabalawoConfig {
    check_unused: otito,      // Check unused variables
    check_taboos: otito,      // Check forbidden patterns
    check_resources: otito,   // Check resource lifecycle
    strict_mode: iro          // Treat warnings as errors
};

check_program()

Main entry point for analyzing an AST.

check_program(program, filename) ? Babalawo

// Returns a Babalawo instance with all diagnostics
ayanmo baba = check_program(ast, "main.ifa");

// Access diagnostics
fun diag ninu baba.diagnostics {
    Irosu.fo(diag.severity + ": " + diag.message);
}

Checks & Rules

Rule Description Severity
undefined-variable Using a variable before declaration Error
unused-variable Declared but never used Warning
missing-return Function should return but doesn't Warning
unclosed-resource Resource opened but not closed (?b? violation) Error
taboo-violation Forbidden dependency between modules Error
unreachable-code Code after return/exit Warning

Taboo System (Èèw?`)

Define forbidden patterns to enforce architectural boundaries:

// In your .ifa config or code header:
èèw?` "ui" ? "database"      // UI cannot import database directly
èèw?` "model" ? "controller" // Models cannot depend on controllers

// Babalawo will error if these patterns are violated

TabooEnforcer

TabooEnforcer

Tracks and enforces forbidden dependency patterns.

ayanmo enforcer = TabooEnforcer.new();
enforcer.add_taboo("source_module", "target_module");

// Check for violations
ayanmo violations = enforcer.check(dependencies);
fun v ninu violations {
    Irosu.kigbe("Taboo: " + v.source + " ? " + v.target);
}

Ìwà Engine (Resource Lifecycle)

Tracks resource acquisition and release to prevent leaks:

// IwaEngine monitors:
// - File handles (Odi.open)
// - Network connections (Otura.connect)
// - Database connections (OduStore.open)
// - GPU resources (GpuContext buffers)

// Babalawo warns if resources are:
// 1. Opened but never closed
// 2. Closed but never opened
// 3. Used after close

Odù Wisdom

Babalawo maps error types to the 16 Odù domains, providing culturally-rooted error messages:

Error Type Odù Proverb
Uninitialized variable Ogbè (The Light) "A journey of a thousand miles begins with a single step."
Missing termination Oyeku (The Seal) "Even the longest night ends with dawn."
Index out of bounds Ogunda (The Cutter) "The machete cuts the path."
Type error Ofun (The Creator) "The child inherits from the parent."

Editor Integration

VS Code

// Install the Ifá-Lang extension
// Babalawo runs automatically on save

// .vscode/settings.json
{
    "ifa.linter.enabled": true,
    "ifa.linter.strict": false
}

Neovim (LSP)

-- In your LSP config
require('lspconfig').ifa_babalawo.setup{
    cmd = { "ifa", "lsp" },
    filetypes = { "ifa" }
}

Programmatic API

// Rust usage (from ifa-babalawo crate)
use ifa_babalawo::{check_program, BabalawoConfig};
use ifa_core::parser::parse;

let source = "ayanmo x = 10";
let ast = parse(source)?;
let baba = check_program(&ast, "test.ifa");

for diag in baba.diagnostics() {
    println!("{}: {}", diag.severity, diag.message);
}