A callable list fold retaining its actual callback #
List.Fold.program adds the shared list traversal to an existing source program.
The selected callback and every original function keep their implementations,
including recursive calls, through the existing typed program embedding.
The correctness contract relates the result to native List.foldl. The callback
may change the heap: the immutable list observation is preserved by source
execution, not by an additional whole-heap-unchanged callback assumption.
Original functions follow the single newly added fold entry.
Equations
- Complexity.Language.List.Fold.calleeMap accTy kind signatures = Complexity.Language.SignatureMap.appendRight [Complexity.Language.List.Fold.foldSignature accTy kind] signatures
Instances For
The new callable fold occupies the first function-table position.
Equations
- Complexity.Language.List.Fold.entry accTy kind signatures = ⟨0, ⋯⟩
Instances For
The selected original callback in the extended function table.
Equations
- Complexity.Language.List.Fold.calleeEntry accTy kind fn = (Complexity.Language.List.Fold.calleeMap accTy kind signatures).toFun fn
Instances For
Add one actual traversal, retaining every original implementation. The function index and its checked signature select the runtime callback.
Equations
- Complexity.Language.List.Fold.program source fn same = source.extend [Complexity.Language.List.Fold.foldSignature accTy kind] (Complexity.Language.List.Fold.addedBody✝ fn same)
Instances For
The fold entry is exactly the shared source traversal with a real call to the relocated callback.
The callback body observed at its declared step signature is the actual renamed original body. Resource contracts may therefore use the same embedding.
Reuse the complete represented callback contract through an actual source-table embedding, with the same mathematical domain and heap effects.
The actual relocated callback reuses its original function contract.
The callable entry returns native folded contents. The original list stays observable in the actual final heap even when callbacks allocate or mutate other source objects.
Mathematical accumulator/list arguments and an observed accumulator result.
Equations
- One or more equations did not get rendered due to their size.
Instances For
The same callable source program refines ordinary List.foldl. Only the
callback's mathematical domain is required along the actual fold prefixes.