Thanks to visit codestin.com
Credit goes to github.com

Skip to content

sunholo-data/ailang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 AILANG: The Deterministic Language for AI Coders

CI Coverage Go Version License

AILANG is a purely functional, effect-typed language designed for autonomous code synthesis and reasoning. Unlike human-oriented languages built around IDEs, concurrency, and sugar, AILANG's design goal is machine decidability, semantic transparency, and compositional determinism.


🧩 Core Philosophy

For humans, a language is a tool for expression. For AIs, it's a substrate for reasoning.

AILANG minimizes ambiguity and maximizes predictability. Every construct — type, effect, or expression — has deterministic semantics that can be reflected, verified, and serialized.


🏗️ Architecture Overview

Layer Description Status
1. Core Semantics Pure functional core with algebraic data types (ADTs), first-class effects, and Hindley-Milner type inference. ✅ Stable
2. Type System Polymorphic effects (! {IO, ε}), Result and Option types, and fully deterministic unification (TApp-aware). ✅ Stable
3. Reflection & Meta-Programming Typed quasiquotes and semantic reflection (reflect(typeOf(f))) for deterministic code generation. 🔜 v0.4.x
4. Deterministic Tooling Canonical normalize, suggest, and apply commands; JSON schema output; --emit-trace jsonl for training data. 🔜 v0.3.15
5. Schema & Hashing Layer Machine-readable type/effect registry and versioned semantic hashes for reproducible builds. 🔜 v0.4.x
6. Runtime & Effects Deterministic evaluator with explicit effect rows; supports IO, FS, Net, Clock; no hidden state or global scheduler. ✅ Stable
7. Cognitive Interfaces JSONL trace export for AI self-training; deterministic edit plans for autonomous refactoring. 🔜 v0.4.x
8. Future Extensions Capability budgets (! {IO @limit=2}), semantic DAG scheduler (schedule { a >> b | c }). 🔮 v0.5.x+

❌ Removed / Deprecated Human-Oriented Features

Removed Feature Reason for Removal
CSP Concurrency / Session Types Replaced by static effect-typed task graphs; no runtime scheduler needed.
Unstructured Macros Replaced by typed quasiquotes (deterministic AST templates).
Type Classes Replaced by structural reflection and record-based traits; removes implicit resolution.
LSP Server Superseded by deterministic JSON-RPC API (ailangd) exposing parser/typechecker directly.
IDE-centric DX Features AIs interact via CLI / API; autocompletion and hover text are unnecessary.

🔮 AI-Native Roadmap

Milestone Goal Example Deliverable
v0.3.15 – Deterministic Tooling Canonical normalization, symbol import suggestion, JSON trace export ailang suggest-imports file.ail
v0.4.0 – Meta & Reflection Layer Typed quasiquotes + reflection API quote (x) -> x + 1 : (int)->int
v0.4.2 – Schema Registry Machine-readable type/effect schemas for deterministic builds /schemas/std/io.json
v0.5.x – Unified Registry Runtime Remove legacy builtin registry; single spec source RegisterBuiltin(spec) unified
v0.6.x – Capability Budgets & DAG Scheduler Deterministic parallelism via static scheduling schedule { parse >> decode | validate }
v1.0 – Cognitive Autonomy Full round-trip reasoning: AI reads, edits, compiles, evaluates, and self-trains from traces --emit-trace jsonl → fine-tuned validator

🧪 Current Milestone: v0.3.17 (CoreTypeInfo Validation & Monomorphization)

  • ✅ CoreTypeInfo validation pass with comprehensive diagnostics
  • ✅ Call-site monomorphization infrastructure (foundation for v0.4.0)
  • ✅ Enhanced compiler diagnostics with debug flags
  • ✅ All 2,847+ tests passing; 100% of examples passing
  • 🔜 Next: Deterministic tooling (normalize, suggest-imports) in v0.3.18

Major Milestones

  • v0.3.17 (Oct 2025): CoreTypeInfo Validation & Monomorphization - Compiler diagnostics + call-site specialization
  • v0.3.16 (Oct 2025): Lambda Expressions Refactor - 6 focused tutorials, entry-module pattern
  • v0.3.15 (Oct 2025): Module Path Fixes - Unified imports, Net builtin migration, capability detection
  • v0.3.14 (Oct 2025): JSON Decode Release - JSON parsing + pattern matching fixes
  • v0.3.12 (Oct 2025): Recovery Release - show() builtin restored (recovers 51% of benchmarks)
  • v0.3.11 (Oct 2025): Critical row unification fix
  • v0.3.10 (Oct 2025): M-DX1 Developer Experience - Builtin system migration (-67% dev time)
  • v0.3.9 (Oct 2025): AI API Integration - HTTP headers, JSON encoding, OpenAI example
  • v0.3.6 (Oct 2025): AI usability - auto-import, record updates, error detection
  • v0.3.5 (Oct 2025): Anonymous functions, letrec, numeric conversions

For detailed version history, see CHANGELOG.md.


💡 Why AILANG Works Better for AIs

Human Need Human Feature AI Equivalent in AILANG
IDE assistance LSP / autocompletion Deterministic type/query API
Asynchronous code Threads / goroutines Static task DAGs with effects
Code reuse Inheritance / traits Structural reflection & records
Debugging Interactive debugger Replayable evaluation trace
Logging print / console --emit-trace jsonl structured logs
Macros text substitution Typed quasiquotes (semantic macros)

🔁 Why AILANG Has No Loops (and Never Will)

AILANG intentionally omits for, while, and other open-ended loop constructs. This isn't a missing feature — it's a design decision rooted in determinism and compositional reasoning.

🧠 For Humans, Loops Express Control. For AIs, Loops Obscure Structure.

Traditional loops compress time into mutable state:

sum = 0
for i in range(0, 10):
    sum = sum + i

This is compact for humans but semantically opaque for machines: the iteration count, state shape, and termination guarantee are implicit.

AILANG replaces this with total, analyzable recursion:

foldl(range(0, 10), 0, \acc, i. acc + i)

or pattern matching:

func sum(list: List[Int]) -> Int {
  match list {
    [] => 0,
    [x, ...xs] => x + sum(xs)
  }
}

Every iteration is a pure function over data, not time — which makes it statically decidable, effect-safe, and perfectly compositional.

⚙️ The Deterministic Iteration Principle

Goal Imperative Loops AILANG Alternative
Repeat a computation for / while map, fold, filter, rec
Aggregate results mutable accumulator foldl / foldr
Early termination break foldWhile / find
Parallel evaluation scheduler threads static task DAGs
Verification undecidable total + effect-typed

🧩 Benefits

  • Deterministic semantics: iteration defined by data, not by time
  • Static totality: no halting ambiguity
  • Composable reasoning: works algebraically with higher-order functions
  • Easier optimization: map/fold can fuse or parallelize safely
  • Simpler runtime: no mutable counters or loop scopes

💡 Future Syntactic Sugar

For readability, AILANG may later support comprehension syntax:

[ p.name for p in people if p.age >= 30 ]

…which desugars deterministically to:

map(filter(people, \p. p.age >= 30), \p. p.name)

No hidden state. No implicit time. Fully analyzable by both compiler and AI.

For the formal rationale and algebraic laws, see the Why No Loops? documentation.


Quick Start

Installation

# From source
git clone https://github.com/sunholo/ailang.git
cd ailang
make install

# Verify installation
ailang --version

For detailed installation instructions, see the Getting Started Guide.

Hello World (Module Execution)

-- examples/demos/hello_io.ail
module examples/demos/hello_io

import std/io (println)

export func main() -> () ! {IO} {
  println("Hello from AILANG v0.3.14!")
}
ailang run --caps IO examples/demos/hello_io.ail
# Output: Hello from AILANG v0.3.14!

Important: Flags must come BEFORE the filename:

# ✅ CORRECT:
ailang run --caps IO --entry main file.ail

# ❌ WRONG:
ailang run file.ail --caps IO --entry main

Interactive REPL

The REPL features full type inference and deterministic evaluation:

ailang repl

λ> 1 + 2
3 :: Int

λ> "Hello " ++ "World"
Hello World :: String

λ> let double = \x. x * 2 in double(21)
42 :: Int

λ> :type \x. x + x
\x. x + x :: ∀α. Num α ⇒ α → α

λ> :quit

REPL Commands: :help, :type <expr>, :instances, :import <module>, :history, :clear

See REPL Commands for full reference.


What AILANG Can Do (Implementation Status)

✅ Core Language

  • Pure functional programming - Lambda calculus, closures, recursion
  • Hindley-Milner type inference - Row polymorphism, let-polymorphism
  • Built-in type class instances - Num, Eq, Ord, Show (structural reflection planned for v0.4.0)
  • Algebraic effects - Capability-based security (IO, FS, Clock, Net)
  • Pattern matching - ADTs with exhaustiveness checking
  • Module system - Runtime execution, cross-module imports
  • Block expressions - { e1; e2; e3 } for sequencing
  • JSON support - Parsing (std/json.decode), encoding (std/json.encode)

✅ Development Tools

  • M-EVAL - AI code generation benchmarks (multi-model support)
  • M-EVAL-LOOP v2.0 - Native Go eval tools with 90%+ test coverage
  • Structured error reporting - JSON schemas for deterministic diagnostics
  • Effect system runtime - Hermetic testing with MockEffContext

🔜 Deterministic Tooling (v0.3.15)

  • ailang normalize - Canonical code formatting
  • ailang suggest-imports - Automatic import resolution
  • ailang apply - Deterministic code edits from JSON plans
  • --emit-trace jsonl - Structured execution traces for training

🔮 Future (v0.4.0+)

  • Typed quasiquotes - Deterministic AST templates
  • Structural reflection - Replace hardcoded type classes
  • Schema registry - Machine-readable type/effect definitions
  • Capability budgets - Resource-bounded effects

📊 Implementation Status

Examples

27/27 examples passing (100%) - Each example exercises specific language features, so this directly reflects implementation completeness.

Example File Status Notes
runnable/adt_option.ail ✅ Pass
runnable/adt_simple.ail ✅ Pass
runnable/block_recursion.ail ✅ Pass
runnable/bug_float_comparison.ail ✅ Pass
runnable/demos/adt_pipeline.ail ✅ Pass
runnable/demos/hello_io.ail ✅ Pass
runnable/effects_basic.ail ✅ Pass
runnable/effects_pure.ail ✅ Pass
runnable/guards_basic.ail ✅ Pass
runnable/json_basic_decode.ail ✅ Pass
runnable/letrec_recursion.ail ✅ Pass
runnable/micro_block_if.ail ✅ Pass
runnable/micro_block_seq.ail ✅ Pass
runnable/micro_io_echo.ail ✅ Pass
runnable/micro_option_map.ail ✅ Pass
runnable/micro_record_person.ail ✅ Pass
runnable/patterns.ail ✅ Pass
runnable/recursion_factorial.ail ✅ Pass
runnable/recursion_fibonacci.ail ✅ Pass
runnable/recursion_mutual.ail ✅ Pass
runnable/recursion_quicksort.ail ✅ Pass
runnable/simple.ail ✅ Pass
runnable/test_fizzbuzz.ail ✅ Pass
runnable/test_guard_bool.ail ✅ Pass
runnable/test_import_func.ail ✅ Pass
runnable/test_io_builtins.ail ✅ Pass
runnable/test_module_minimal.ail ✅ Pass

See Full Implementation Status for detailed breakdown with auto-updated table of all examples.


Documentation

📖 Complete Documentation - Visit our full documentation site

Quick Links:


Development

# Build and install
make install

# Run tests
make test

# Start REPL
make repl

# Run example
make run FILE=examples/hello.ail

# Auto-rebuild on changes
make watch-install

# Check coverage
make test-coverage-badge

# AI Evaluation & Design Generation
make eval-suite          # Run AI benchmarks (AILANG vs Python)
make eval-report         # Generate evaluation report
make eval-analyze        # Analyze failures, generate design docs

See the Development Guide for detailed instructions.


📚 Specification Reference

  • Core: /internal/types/, /internal/eval/
  • Effects: /internal/effects/
  • Builtins: /internal/builtins/spec.go
  • Standard Library: /stdlib/std/*
  • Design Docs: /design_docs/

Project Structure

ailang/
├── cmd/ailang/         # CLI entry point
├── internal/           # Core implementation
│   ├── repl/           # Interactive REPL
│   ├── lexer/          # Tokenizer
│   ├── parser/         # Parser
│   ├── types/          # Type system
│   ├── eval/           # Evaluator
│   ├── effects/        # Effect system runtime
│   ├── builtins/       # Builtin registry
│   └── eval_harness/   # AI evaluation framework
├── stdlib/             # Standard library
├── examples/           # Example programs
├── docs/               # Documentation
└── design_docs/        # Design documents

Contributing

AILANG is an experimental language in active development. Contributions are welcome! Please see the Development Guide for guidelines.


⚖️ License & Philosophy

AILANG is open infrastructure for Cognitive DevOps — systems that write, test, and deploy themselves deterministically.

Our design north star: build languages AIs enjoy using.

Apache 2.0 - See LICENSE for details.


Acknowledgments

AILANG draws inspiration from:

  • Haskell (type system, purity)
  • OCaml (module system, effects)
  • Rust (capability-based security)
  • Idris/Agda (reflection and metaprogramming)

For AI agents: This is a deterministic functional language with Hindley-Milner type inference, algebraic effects, and explicit effect tracking. The REPL is fully functional. Module execution works with capability-based security. See CLAUDE.md and Complete Documentation for exact capabilities.

About

For humans, a language is a tool for expression. For AIs, it's a substrate for reasoning.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •