Typed policies. Deny-by-default tools.

Make Agent actions
readable before execution.

Write ordered policies over typed inputs, require approval for risky tools, and inspect deterministic outcomes. Your code runs entirely in the browser and is never sent to a server.

Try it now TeaVM client runtime
0.16Current version
204Automated tests
0Server dependencies
Interactive runtime

Run Yin right here

Choose an example, edit the code, then press +Enter to run it.

Language
Runnable demos
main.yin
Result
Loading the Yin runtimeAbout 150 KB on first load
Language tour

Small language. Clear semantics.

Yin is more than a syntax toy: its interpreter and type checker share one thoroughly tested language specification.

01

Lexical closures

Functions capture the environment where they are defined. Interactive redefinitions do not rewrite existing closures.

(define make-adder
  (fun (base)
    (fun (value) (+ base value))))
02

Static types

Arguments, return values, and assignments are checked before execution, with precise source locations for errors.

IntFloatBoolStringAny
03

Union types

(U Int Float) expresses multiple possibilities under explicit subtype rules.

04

Nominal record inheritance

Construct typed records, inherit fields transitively, and read them without sacrificing static types.

(record Point [x Int] [y Int])
(define point (Point :x 10 :y 20))
(field point :x)
05

Immutable vectors

Read, measure, and combine fixed vectors with precise element types and checked bounds.

(define values (append [10 20] [30 40]))
(length values)
(at values 3)
06

Pattern-driven programs

Narrow unions, destructure immutable data, and combine typed collection and string operations.

(match (parse-int "42")
  [(Int value) (+ value 1)]
  [(Bool _) 0])
07

Explicit outcomes

Represent expected failure as typed data and handle every success and error path before execution.

(match (fetch true)
  [(Ok value) value]
  [(Err message) (report message)])
08

Structured contracts

Decode untrusted JSON into a closed source type, handle structured errors, and export the same contract as JSON Schema.

(match (decode-json Request text)
  [(Ok request) (handle request)]
  [(Err error) (field error :path)])
09

Guarded tool runtime

The JVM reference host checks installed capabilities, requires explicit write approval, and records a hash-chained trace that can be replayed without repeating effects.

yin --guard policy.yin --host host.json --trace run.jsonl
yin --replay run.jsonl
10

Deterministic decision contracts

The JVM contract profile rejects ambient effects and binds the exact policy, input, and structured decision with SHA-256 digests.

yin --contract-check policy.yin
yin --contract-run policy.yin --input request.json