Skip to content
/ if-lang Public

An intent‑first, constrained general‑purpose language for LLM‑generated programs.

License

Notifications You must be signed in to change notification settings

KKould/if-lang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IF Lang

github star github fork

An intent-first, constrained general-purpose functional language designed for clear meaning and low token usage. It favors pure functions, explicit data flow, and no hidden state.

Goal: help LLMs generate minimal detail and clear computational intent, with strict constraints and compile/eval layers ensuring deterministic semantics.

For the full language notes, see AGENTS.md.

Why this language

This project is built to address three practical pain points when using LLMs for code generation:

  1. unclear expression of intent (high review cost, overgrown scaffolding),
  2. hallucinated or noisy implementation details (diluted intent, extra context),
  3. inflated token usage and higher cost from the above.

IF Lang is intended as a pre‑implementation logic layer: LLMs first generate a small, precise POC or draft in IF Lang for human review, then either a human or an LLM produces the concrete implementation in the target language.

  • Intent-first: pipelines (x |> f(a)) read like steps.
  • Pure by default: no implicit mutation or IO.
  • Explicit externs: host-provided functions must be declared.
  • Strong constraints: parameter usage order must match signature order.

Syntax

Full syntax reference: SYNTAX.md.

Codex skill

This repo includes a Codex skill for IF Lang: SKILL.md. Use it to guide IF Lang edits, enforce constraints (externs, parameter order, pipeline style), and keep logic in IF Lang with minimal extras.

Example

One-line scripts (requires cargo install if_lang) — Python extra by default:

./scripts/run_bst_topk.sh
./scripts/run_mini_web.sh
./scripts/run_mini_sql.sh

Tip: pass rust as the optional parameter to run the Rust extra(e.g. ./scripts/run_mini_sql.sh rust).

Run directly with extras:

# Python extra (.py)
if_lang extra examples/bst_topk_extra.py examples/bst_topk.if

# Rust extra (.rs, compiled to dylib on the fly)
if_lang extra examples/bst_topk_extra.rs examples/bst_topk.if

# Rust extra (prebuilt dylib)
if_lang extra path/to/libbst_topk_extra.so examples/bst_topk.if

Format IF source (rustfmt-style UX):

# Format in-place
if_lang fmt examples/bst_topk.if

# Check formatting (non-zero exit if different)
if_lang fmt --check examples/bst_topk.if

# Format from stdin to stdout
cat examples/bst_topk.if | if_lang fmt -

Notes

  • Constructors are Uppercase and use field syntax: Node { value, left, right }
  • match supports field destructuring and comparison patterns (e.g. >= 80)
  • Extern functions must be declared with an explain { ... } block and registered at runtime

Editor support

  • VS Code extension (syntax highlighting + diagnostics): editors/vscode

VS Code usage

  1. Build or install the CLI so if_lang is available on your PATH (e.g. cargo install if_lang).
  2. In VS Code, run “Developer: Install Extension from Location...” and select editors/vscode.
  3. Open a .if file. Diagnostics run on save by default.

Settings:

  • iflang.cliPath: Path to the if_lang CLI (default: if_lang).
  • iflang.diagnosticsMode: onSave (default), onType, or off.
  • iflang.diagnosticsDebounceMs: Debounce time (ms) for onType.

Features:

  • Syntax highlighting.
  • Diagnostics via if_lang check.
  • Go to Definition / Find References (workspace-wide, best-effort).

About

An intent‑first, constrained general‑purpose language for LLM‑generated programs.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published