| ▲ | bbminner 2 hours ago | |||||||
I have not looked into the HM algorithm much, but is there (an educational or performance wise) advantage over implementing a (dumb) SAT solver and expressing a problem as a SAT problem? It always seemed like the "natural representation" for this kind problem to me. Does knowing that these are types _specifically_ help you somehow / give you some unique insights that won't hold in other similar SAT problems? | ||||||||
| ▲ | octachron an hour ago | parent | next [-] | |||||||
For a bounded size of types of sub-expressions, HM inference is quasi-linear in the size of the program, because the constraints appearing in the HM algorithm are only equality between meta-variables.A NP-complete SAT solver is not really a good fit for this kind of simple constraints. Even more so when typechecking often represents a significant part of compilation time. (Of course the tricky part of the definition above is that the size of types can theoretically be exponential in the size of a program, but that doesn't happen for programs with human-understandable types) | ||||||||
| ▲ | remexre 2 hours ago | parent | prev | next [-] | |||||||
how would you encode a program like
in sat?if that's easy, how about length and f in:
hm-style inference handles polymorphism and type application without a complicated sat encoding | ||||||||
| ▲ | recursivecaveat 2 hours ago | parent | prev [-] | |||||||
Keep in mind one of the most important attributes of a good compiler is clearly explaining to the user what caused compilation failure and why. If you try to solve in a very abstract and general space it could be challenging to give an actionable error message. | ||||||||
| ||||||||