-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Description
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:
effekt/effekt/jvm/src/main/scala/effekt/Repl.scala
Lines 318 to 319 in aa897e4
| 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
effekt/libraries/common/effekt.effekt
Lines 102 to 104 in aa897e4
| extern io def inspect[R](value: R): Unit = | |
| js { println(genericShow(value)) } | |
| chez { println(genericShow(value)) } |