Skip to content

ilkModel your Domain, type check your data flow

Example concrete usecase is declare a json-schema with higher-level constraints it has to respect

Try it ​

Type
live compiler >
Loading compiler…

The idea in 30 seconds ​

A .ilk file has two sections: meta declarations and instance bindings.

  • Types define abstract shapes β€” what fields exist, what types they have, what constraints apply.
  • Instances name the concrete entities in your domain β€” not runtime values, but a typed catalog of the things your system knows about.
ilk
// Meta declaration
meta HttpResponse = {
    status! Concrete<Int> // required (!), Concrete<...> means instances have to declare a value
    body {...} // open : any fields allowed, no constraints
}

// Instances
creationSuccess = HttpResponse {
    status 201
    body {uid Uuid}
}

notFound = HttpResponse {
    status 404
}

userProfile = HttpResponse {
    status 200
    body {
        uid Uuid
        name String
        admin Bool
        email String
    }
}

The key feature: data flow ​

Traditional schemas validate shape. ilk also validates where data comes from.

@source declares which upstream fields may supply data to a downstream field. Every open field must be explicitly mapped β€” the compiler checks it.

Type
live compiler >
Loading compiler…

Quick reference ​

Value constraint levels ​

Type formInstance formMeaning
StringStringOpen β€” any value at runtime
Concrete<String>"webhook"Instance-fixed β€” instance author picks one
"POST""POST"Type-fixed β€” must match exactly

Structs ​

ilk
{_}              // exactly 1 field of any name/type
{_ String}       // exactly 1 field, meta String
{...}            // any fields (open)
{id Uuid}        // specific named fields
{...} & {id Uuid} // any fields + required id

Lists ​

ilk
[]Event      // 0+ elements
[3]Tag       // exactly 3
[1..]Tag     // 1 or more
[2..5]Tag    // 2 to 5
[..10]Tag    // up to 10
&Event       // reference to a binding (no data flow)
[]&Event     // list of references

Unions ​

ilk
meta HttpMethod = "GET" | "POST" | "PUT"   // literal union
meta Status = Pending | Active | Archived  // identifier union
meta Tag = {_ String} | Concrete<String>   // mixed

Annotations ​

AnnotationPurpose
@mainEntry point β€” compiler validates from here
@source [fields]Data provenance: values must trace back to fields
@constraint exprBoolean predicate validated at compile time
@doc "…"Implementation hint, preserved in AST