Open Camto opened 6 years ago
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.
Thanks for the response. I hope you can find an answer!
I have a program
Say lambda.ktn
which contains:It prints
And when I type in the console
6 -> x {x say} call
it prints6
, so far so good. But when I type6
,-> x {x say}
, andcall
in separate lines (like in the file), it saysI can't find an instantiation of '_::show': _::show<T>
, which it should not. It should print6
. It says the same error for"Lambda!"
.