evincarofautumn / kitten

A statically typed concatenative systems programming language.
http://kittenlang.org/
Other
1.08k stars 39 forks source link

Errors in tutorial #208

Open antoyo opened 6 years ago

antoyo commented 6 years ago

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 commented 6 years ago

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 (32fa225eb7fd3e94a7dc3a67575c44a73499a3bf) 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.