(A diagram showing how the context-sensativity of the specialization type signature can create repeating patterns instead of simple recursion)
To illustrate what I mean by wanting to only use “local properties”, consider if
fuchsia entered inference first, then inference will see the widening recursion at
green´ will not be encountered. Thus, the result of
green will be different than if
fuchsia was not being inferred (recursion would have been detected at
green´, changing the results assigned and cached for both – including
fuchsia when it is later inferred, and uses the cached return type for
An optimal limit would notice the recursion at
fuchsia´, but change the topmost function (
fuchsia) to use an approximation of
green while canceling type-inference on the original attempted edges. This would preserve the characteristic that the cached result of type-inferring
green shouldn't depend on having been called from
A downside of the current arbitrary limits is that they penalize valid code which uses complex types, even if they are not changing under recursion.
Another downside is that it only takes into account the possibility of expressing memory via the type-system "length" and "depth" definitions above.
These challenges remain, and will need to be addressed in a future update to this blog (and to the implementation!).