[Haskell-cafe] Type-level naturals & multiplication
simonpj at microsoft.com
Tue Oct 13 03:37:51 EDT 2009
| > Is there any way to define type-level multiplication without requiring
| > undecidable instances?
| No, not at the moment. The reasons are explained in the paper "Type
| Checking with Open Type Functions" (ICFP'08):
| We want to eventually add closed *type families* to the system (ie,
| families where you can't add new instances in other modules). For
| such closed families, we should be able to admit more complex
| instances without requiring undecidable instances.
It's also worth noting that while "undecidable" instances sound scary, but all it means is that the type checker can't prove that type inference will terminate. We accept this lack-of-guarantee for the programs we *run*, and type inference can (worst case) take exponential time which is not so different from failing to terminate; so risking non-termination in type inference is arguably not so bad.
More information about the Haskell-Cafe