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

Errors in tutorial #208

Open
antoyo opened this issue Jun 25, 2018 · 1 comment
Open

Errors in tutorial #208

antoyo opened this issue Jun 25, 2018 · 1 comment

Comments

@antoyo
Copy link

antoyo commented Jun 25, 2018

Hi.
I tried the example from this page and the call to say does not work.
Here's the result:

What is your name? kitten: user error (Pattern match failure in do expression at lib/Kitten/Interpret.hs:628:9-22)

You need to remove the print on the first line.
(And, to be quite honest, the error message is very confusing, so it would be good to improve it as well.)

Also, string concatenation with + does not seem to work.
The following code:

("Meow, " + name + "!") say

gives me the following error:

kitten: I can't find an instantiation of '_::+': '_::+::<_::List<_::Char>>'

Is there anything wrong in this code?

Thanks.

@evincarofautumn
Copy link
Owner

Thanks, there’s nothing wrong with the code, it’s just a mismatch between the book and the implementation. I’ve removed that stray print. That error message is caused by a bug in the typechecker which has been fixed in the upcoming version.

String concatenation with + doesn’t work because the current version is missing support for generic instances. You can use the cat function instead, and for now (32fa225) I’ve added this as a workaround:

instance + (List<Char>, List<Char> -> List<Char>):
  cat

Ideally it should be this for any type T, but the compiler will fail to instantiate it:

instance + <T> (List<T>, List<T> -> List<T>):
  cat

This will also be fixed in the next version.

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

No branches or pull requests

2 participants