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

No multiline generic lambdas in REPL #198

Open
Camto opened this issue Dec 9, 2017 · 2 comments
Open

No multiline generic lambdas in REPL #198

Camto opened this issue Dec 9, 2017 · 2 comments

Comments

@Camto
Copy link

Camto commented Dec 9, 2017

I have a program Say lambda.ktn which contains:

6
-> x {x say}
call
"Lambda!"
-> x {x say}
call

It prints

6
Lambda!

And when I type in the console 6 -> x {x say} call it prints 6, so far so good. But when I type 6, -> x {x say}, and call in separate lines (like in the file), it says I can't find an instantiation of '_::show': _::show<T>, which it should not. It should print 6. It says the same error for "Lambda!".

@evincarofautumn
Copy link
Owner

Thanks for bringing this to my attention. I was aware of this bug, but unfortunately I haven’t found a great way to solve it yet.

Essentially, each entry in the console is added to the interpreter state as a separate definition, partly so that they can be referenced later as interactive::entryN. When one of these definitions is generic, like -> x { x say } by itself†, the compiler fails to generate an instantiation of that definition for a particular concrete type, so instead of looking up show<Int32> or show<List<Char>>, it tries to look up the generic show<T>, which fails because that’s not a real instance definition.

For now you can work around this by avoiding generic entries in interactive mode, or using a source file, but I’ll bump this up on my to-do list and figure out how to fix it properly.

†NB: This is unrelated to your question, but the type of -> x { x say } is currently slightly wrong as well: it’s inferred as <T> (-> (T -> +IO)), but it should eventually include a trait constraint, something like <T> (-> (T -> +IO)) where (show<T>). This should help the compiler produce a better error message in similar situations.

@Camto
Copy link
Author

Camto commented Dec 10, 2017

Thanks for the response. I hope you can find an answer!

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