Files
tricu/demos/viewContracts/frontendEmission
James Eversole fdebb6c13d Tricu 2.0.0
Sorry for squashing all of this but 🤷
2026-05-25 12:44:24 -05:00
..
2026-05-25 12:44:24 -05:00
2026-05-25 12:44:24 -05:00
2026-05-25 12:44:24 -05:00
2026-05-25 12:44:24 -05:00

Frontend Emission Demos

These examples show the layer between source-level View annotations and the portable View Contract checker.

Each *.source.txt file is pseudo-source: it is not parsed by tricu. It shows the information a frontend has after parsing/elaboration.

Each matching *.emitted.tri file shows the lowered typed-program metadata that a frontend can emit today. A successful check returns checked-exec; these demos focus on structural Views, so they report "ok" as soon as metadata checking succeeds. Guarded programs should run the returned checked-exec with runChecked, as shown in demos/viewContracts.tri and by tricu check.

Successful map use

Pseudo-source:

map : Fn [Fn [Bool] String, List Bool] (List String)
f   : Fn [Bool] String
xs  : List Bool

partial = map f
out     = partial xs

require out : List String

Run the emitted artifact:

tricu eval demos/viewContracts/frontendEmission/map-success.emitted.tri -f decode

Expected output:

"ok"

Wrong list argument

Pseudo-source:

map : Fn [Fn [Bool] String, List Bool] (List String)
f   : Fn [Bool] String
xs  : List String

partial = map f
out     = partial xs

Run:

tricu eval demos/viewContracts/frontendEmission/map-wrong-list.emitted.tri -f decode

Expected output:

"symbol 162 expected List Bool but got List String"

Wrong filter predicate

Pseudo-source:

filter : Fn [Fn [Bool] Bool, List Bool] (List Bool)
pred   : Fn [Bool] String
xs     : List Bool

partial = filter pred
out     = partial xs

Run:

tricu eval demos/viewContracts/frontendEmission/filter-wrong-predicate.emitted.tri -f decode

Expected output:

"symbol 181 expected Fn [Bool] Bool but got Fn [Bool] String"

Lowering shape

A frontend does not need to expose tricu syntax internally. It only needs to emit portable typed-program nodes:

typedValue symbol view term
typedApply out callee arg term
typedRequire symbol view term

The source-level flow:

out = map f xs

lowers to curried Tree Calculus application nodes:

typedApply partial map f partialTerm
typedApply out partial xs outTerm

Function Views drive argument checking and result inference.