Gradual Types and Runtime Cast Boundaries
Follow a value across a typed boundary and see why checking a function requires obligations on later calls and returns.
- Source
- Anbloq
- Language
- English
- Created
- Updated
- Chapters
- 2
- Reading time
- 1 min
In this article2 chapters
Dynamic values can carry evidence for later checks
A gradual language can let an unannotated value flow into a context requiring an integer. A runtime cast then checks whether the value satisfies that expectation. Success yields a value valid for the receiving context. Failure is associated with a boundary whose contract could not be met. The exact consistency relation and cast insertion rules belong to the language’s model.
A function contract can require a wrapper
Suppose a dynamic function is used as a function from integers to Booleans. Merely observing that it is callable cannot guarantee its future results. A cast can wrap it so each call respects the argument contract and each returned value is checked for Boolean type. Higher-order checking follows both sides of the variance rules. Gradual typing theory formalizes how changing annotations affects static acceptance and dynamic behavior.[1][2]