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

REPL throws an error when attempting to show a term #474

Open
jiribenes opened this issue May 28, 2024 · 2 comments
Open

REPL throws an error when attempting to show a term #474

jiribenes opened this issue May 28, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@jiribenes
Copy link
Contributor

jiribenes commented May 28, 2024

Problem

When I put an expression into the REPL, the REPL tries to call println($EXPR) which fails for all non-trivial types since #449:

> type TrafficLight { Red(); Yellow(); Green() }
> Red()
[error] Cannot typecheck call.
There are multiple overloads, which all fail to check:
[...]
Full error
Possible overload: option::println of type Option[Double] => Unit
  Argument count does not match TrafficLight2360 vs. Option593
  Expected type
    Option[Double]
  but got type
    TrafficLight

Possible overload: effekt::println of type String => Unit
  Expected String but got TrafficLight.

Possible overload: effekt::println of type Int => Unit
  Expected Int but got TrafficLight.

Possible overload: array::println of type Array[String] => Unit
  Argument count does not match TrafficLight2360 vs. Array1667
  Expected type
    Array[String]
  but got type
    TrafficLight

Possible overload: option::println of type Option[Bool] => Unit
  Argument count does not match TrafficLight2360 vs. Option593
  Expected Option[Bool] but got TrafficLight.

Possible overload: list::println of type List[Int] => Unit
  Argument count does not match TrafficLight2360 vs. List767
  Expected List[Int] but got TrafficLight.

Possible overload: option::println of type Option[Int] => Unit
  Argument count does not match TrafficLight2360 vs. Option593
  Expected Option[Int] but got TrafficLight.

Possible overload: list::println of type List[Double] => Unit
  Argument count does not match TrafficLight2360 vs. List767
  Expected List[Double] but got TrafficLight.

Possible overload: effekt::println of type Unit => Unit
  Expected Unit but got TrafficLight.

Possible overload: list::println of type List[String] => Unit
  Argument count does not match TrafficLight2360 vs. List767
  Expected List[String] but got TrafficLight.

Possible overload: array::println of type Array[Bool] => Unit
  Argument count does not match TrafficLight2360 vs. Array1667
  Expected Array[Bool] but got TrafficLight.

Possible overload: effekt::println of type Double => Unit
  Expected Double but got TrafficLight.

Possible overload: array::println of type Array[Double] => Unit
  Argument count does not match TrafficLight2360 vs. Array1667
  Expected type
    Array[Double]
  but got type
    TrafficLight

Possible overload: list::println of type List[Bool] => Unit
  Argument count does not match TrafficLight2360 vs. List767
  Expected List[Bool] but got TrafficLight.

Possible overload: effekt::println of type Ordering => Unit
  Expected Ordering but got TrafficLight.

Possible overload: effekt::println of type Bool => Unit
  Expected Bool but got TrafficLight.

Possible overload: array::println of type Array[Int] => Unit
  Argument count does not match TrafficLight2360 vs. Array1667
  Expected Array[Int] but got TrafficLight.

Source

Here's the code in question which just calls println on terms:

def makeEval(expr: Term): ModuleDecl =
make(Call(IdTarget(IdRef(List(), "println")), Nil, List(expr), Nil))

Potential solution

If we don't want to wait for typeclasses #66, we could instead use inspect introduced in #449 because the REPL always runs with the JavaScript backend:
EDIT: Not true, the REPL runs with the backend of user's choice, see below. The workaround would only work for the JS and Chez backends

extern io def inspect[R](value: R): Unit =
js { println(genericShow(value)) }
chez { println(genericShow(value)) }

@jiribenes jiribenes added the bug Something isn't working label May 28, 2024
@marvinborner
Copy link
Member

the REPL always runs with the JavaScript backend:

For debugging I often use different backends in the REPL, e.g. via effekt.sh --backend llvm
Am I misunderstanding this?

@jiribenes
Copy link
Contributor Author

Thanks, I took a closer look and invalidated my assumption. The REPL runs for any backend...
I'll fix it in the original issue description.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants