Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Main: Qlzqqlzuup.hs:(215,9)-(236,42): Non-exhaustive patterns in function qForEach #1

Closed
LegionMammal978 opened this issue Mar 28, 2016 · 4 comments
Labels

Comments

@LegionMammal978
Copy link

This error is generated when trying foreach on any cyclic list, causing the interpreter as it stands to be Turing-incomplete.

@cpressey
Copy link
Member

Well, the more important thing than Turing-completeness or lack thereof would be that the interpreter implements some language other than what's described in the spec...

And it doesn't seem to be on any cyclic list, because if I try the program given in the README:

foreach $x$ = :L:[1, 2, 3, goto L] with $a$ = 0 be $x$ else be null

I get a different error:

qlzqqlzuup: Qlzqqlzuup.hs:363:25-60: Irrefutable pattern failed for pattern ((Qlzqqlzuup.Ident label), rest)

So there may in fact be more than one problem here.

Can you provide the Quylthulg program you tried that gave you your error message?

EDIT: for bonus points, if you could phrase it in the form of a PR that adds a test case based on your Quylthulg program to tests/Quylthulg.markdown, that'd be fantastic.

@cpressey cpressey added the bug label Mar 30, 2016
@LegionMammal978
Copy link
Author

On that one, the goto has incorrect syntax. The program that produced the error was something along the lines of:

foreach $x$ = :L:[1, 2, 3, goto $L$] with $a$ = 0 be $x$ else be null

(That should be fixed in the README.) In fact, none of the current tests includes a foreach on an infinite list.

@cpressey
Copy link
Member

Thanks. Yes, when I started investigating I noticed the syntax error there too, which I will fix in the README as part of this. The real problem seems to be that both labels and gotos aren't handled correctly while consuming the list being foreach'ed over. I have what I think is a fix but I'd like to write a test case or two for it first, and obviously we can't have a test case that actually does loop forever... so I'm going to have to write an example program that terminates on some condition. (Which shouldn't be too hard, aside from the fact that I'll have to write it in Quylthulg, naturally.)

@cpressey
Copy link
Member

The last few commits ought to have fixed the problem: b6c9f58...a79f8fd

In particular, this example program takes the "first 5" elements of a cyclic list.

While writing the new test cases, I was a bit worried that Quylthulg is not actually Turing-complete, but I seem to have since re-convinced myself that it is. The snags are:

  • While you can express conditionals, you can only express them on lists (with e.g. null = false, [1] = true). You can't express them on integers.
  • That's not an insurmountable problem, because you can just forget about the integer type, and represent natural numbers as lists, using the length.
  • But then, if you have a list of integers, you might not be able to process it in the way you want, because foreach is "recursing", and will try to apply the loop-expr to the contents of each integer in the list.
  • But that's probably not an insurmountable problem either. You could, for example, encode your list of integers into something like a Gödel number (represented as a list...)
  • And if you're prepared you do that, you could probably write a two-counter Minsky Machine emulator in Quylthulg, showing it is Turing-complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants