property Pool<T> { ... }, function first<T>(xs: []T) -> T, map<T, U> over fn
types; a type writes an instance as Pool<Thing>, nested as deep as needed. The
parser names an instance Pool$Thing and remembers its generic and arguments; the
checker takes the generic declarations out, infers a call's type arguments from
its arguments or its result's declared slot, and makes each instance once as an
ordinary record or function, checked like any other. Errors print Pool<Thing>.
An instance keeps its generic's module and export (L3). ludic-fmt keeps type
arguments together while spacing comparisons and shifts.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
9 lines
267 B
Text
9 lines
267 B
Text
# L5: a call whose type arguments nothing decides is refused - give the result a declared type
|
|
program GenericUnbound {
|
|
property Pool<T> { n: int = 0 }
|
|
function pool_new<T>() -> Pool<T> { return new Pool<T> }
|
|
entry {
|
|
let p = pool_new()
|
|
print(p.n)
|
|
}
|
|
}
|