Parity of nested function type and recursive call

49 views Asked by At

I'm working on recursive types (involving only functions; a -> b). For each type with one self-reference I can tell whether it's possible to write a function that calls itself with that type. For exmaple, with the type "T: T -> x" (for any arbitrary x) one can construct the function (T) => T(T), which inhabits the type and calls itself. However, for the type "T: x -> T" it's not possible. Another example is the type "T: (T -> r) -> r" for all r. This type resembles a map function, and in this case it's also not possible to inhabit with a function that calls itself.
Is there a general rule to determine whether a type of this form can be inhabited with a recursive function or not?

I noticed an interesting pattern if we count the number of functions in which the self-reference is on the left/argument position. The examples where recursion was possible were all odd, while the others were even, but I don't have a proof for this pattern at all.

0

There are 0 answers