From reading Wikipedia entry for lambda cube and this thread, when apply to Haskell, my understanding is that
- family of terms indexed by terms - typical function from value to value
- family of terms indexed by types - ??
- family of types indexed by types - parametric polymorphism in type constructors, type families
- family of types indexed by terms - pi types (in which you fake with singleton types in Haskell), sigma types, etc...
Please correct me if I got the examples listed above wrong. Quoting from that Wikipedia article:
- Terms depending on types, or polymorphism. System F, aka second order lambda calculus (written as λ2 in the diagram), is obtained by imposing only this property.
I do not know how Haskell fits into this (2) from above. Haskell has a strong distinction between terms and types, and type erasure, so you do not have reflection stuff in OOP such as typeof(a)
or b.GetType()
, and then proceed to return some value based on type information at run time.
So the only thing I can think of in Haskell relating to (2) are maybe
- Return type polymorphism in say
mempty
inData.Monoid
, where the value depends on the instance type - Data families where you take in types on the LHS and have value constructors on the RHS
Would that be correct? Though I feel like I didn't make all the connections...
Would it be correct to say ad-hoc polymorphism satisfies (2) while parametric polymorphism satisfies (3)? But then how does ad-hoc vs parametric relates to difference in RHS of type vs data families?
One last thing, how would sum type values such as
Nothing :: forall a. Maybe a
Right 3 :: forall a. Num b => Either a b
when they lack type context fit into this picture? My guess would be that this is an example of (2)?