Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

“Arbitrary prolog in Haskell’s type system” is overselling it.

There are a lot of GHC extensions out there, so maybe some combination of extensions can bring this statement closer to reality. But, as stated, it’s pretty far away. There’s an important common thread shared by Prolog and type certain systems, which is unification, but Prolog gives you a lot of tools to control what happens when you go forward and backward:

      +---+
  >---|   |--->
      |   |
  <---|   |---<
      +---+
Prolog is, after all, Turing complete by design. I don’t know if Haskell’s type system is Turing complete with enough GHC extensions enabled, but if it is, then it’s by accident.


You need very little to make a Prolog-like language Turing-complete (lists and recursive predicates). And so Haskell's type system only needs one (or two) extensions to be Turing-complete, `UndecidableInstances` (and maybe `FlexibleInstances` or `MultiParamTypeClasses`). It is no accident. The name "undecidable" shows that the authors of that extension were well aware that it enables Turing-completeness.


Exactly—Haskell’s type checker can be made Turing-complete, but that won’t make it much like Prolog.


I'm not sure how useful it is in practice but even C++ templates are turing complete. https://rtraba.com/wp-content/uploads/2015/05/cppturing.pdf

> I don’t know if Haskell’s type system is Turing complete with enough GHC extensions enabled, but if it is, then it’s by accident.

Undecidable instances? I don't think that's an accident. https://stackoverflow.com/questions/42356242/how-can-undecid...

Also see. https://github.com/seliopou/typo


True, I'm not sure you're going to get anything like cuts in a type system. I know with Haskell (GHC really, but that's kind of a given these days) and C++ you can make matching abort early, but only with an error.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: