Question

I'm looking for the name used to refer to generic types that are equivalent under nesting. That is to say, you don't get "different values" by nesting the type inside itself.

For example, an Async<Async<int>> can be treated as equivalent to an Async<int>, and I want to know what to call an Async type that actually has this equivalence property.

// Async<int> == Async<Async<int>>
Async<int> r1 = Async.Done(Async.Done(1))
Async<Async<int>> r2 = r1
Async<int> r3 = r2

My intuition is to call them "Collapsing Types" or "Idempotent under Nesting", but I really have no idea what the proper term is.

Was it helpful?

Solution

I suppose you'd call that an idempotent type constructor. However, I have never seen this showing up, except perhaps in the case of some type modalities in a modal type theory (which is rather esoteric). For built-in/abstract type constructors it simply makes no sense! In any properly designed type system you will only have C(C(T)) = C(T) if also C(T) = T (injectivity). In particular, Async should not be idempotent either, since there is a difference in the number of synchronisations that objects of these respective types abstract, and that makes a computational difference.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top