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))))
Explore Yin's implemented hosted language with immutable values, exhaustive outcomes, and strict typed boundaries. The long-term compiler architecture targets constrained runtimes without claiming those backends exist today. Your code runs entirely in the browser and is never sent to a server.
Choose an example, edit the code, then press ⌘+Enter to run it.
read-all
void
void
Educational demo only. Anyone with this key controls the wallet. Never fund this address.
Hidden until you reveal it
Yin is more than a syntax toy: its interpreter and type checker share one thoroughly tested language specification.
Functions capture the environment where they are defined. Interactive redefinitions do not rewrite existing closures.
(define make-adder
(fun (base)
(fun (value) (+ base value))))
Arguments, return values, and assignments are checked before execution, with precise source locations for errors.
IntFloatBoolStringAny(U Int Float) expresses multiple possibilities under explicit subtype rules.
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)
Use vectors, insertion-ordered dictionaries, and sets with persistent updates and safe optional lookup.
(define config (dict "mode" "dev"))
(dict/get config "mode")
(dict/put config "port" "8080")
Narrow unions, destructure immutable data, and combine typed collection and string operations.
(match (parse-int "42")
[(Int value) (+ value 1)]
[(Bool _) 0])
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)])
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)])
Modules expose an explicit public surface. Every reachable dependency is type-checked and each module initializes once.
(import "./validation.yin"
[validate-config])
(validate-config config)
Typed tools, ordered policies, guarded hosts, and portable deterministic contracts remain available when an embedder needs explicit authority.
yin --capabilities program.yin
yin --contract-check decision.yin