Investigate delayed substitutions in types
GHC's type representation can sometimes blow up. See
- #19668 (closed), or more specifically the types in T9198
- #5642
- #12618
- #13059 (closed)
- #16577
The problem is that when you have a nested tuple application, e.g. ((4,True),('c','d'))
, the size of the type arguments grows quadratically with the expression size. This bites badly in some approaches to generic programming, which use nested tuples heavily.
It's explained in detail in Section 2.3 of Scrap your type applications.
One solution might be to switch to the type system of "Scrap your type applications". But that would be a Big Deal.
A more modest approach is to use delayed substitutions. Here is a wiki page describing the delayed-substitution idea. This ticket is to track progress on investigating that idea.