You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes#722 and adds basic support for string templates.
There are a few caveats to keep in mind with the current initial
implementation:
- All arguments already have to be strings. It is basically just
syntactic sugar so that you can write `"${a.show} and ${b.show}"`
instead of `a.show ++ " and " ++ b.show` where `a` and `b` are some
'showable' values. Internally, however, this is just how it is
desugared.
- String templates cannot be used to match string literals in pattern
matches
- The generated JS code looks a bit weird:
```
const v_r_897 = $effekt.println(((((((((("GET ") + (domain_0)))) +
(((("/users/") + (user_0))))))) + (((("/resource/") + (('' +
resourceId_0))))))));
```
+ If one forgets to call `show` on arguments which are not already of
type string, the error messages are hideous and possibly confusing:
<details>
<summary>error</summary>
```
-There are multiple overloads, which all fail to check:
-Possible overload: effekt::println of type Bool => Unit
- Expected String but got Int.
- Expected Bool but got String.
-
-Possible overload: list::println of type List[Bool] => Unit
- Expected String but got Int.
- Expected List[Bool] but got String.
-
-Possible overload: array::println of type Array[Int] => Unit
- Expected String but got Int.
- Expected Array[Int] but got String.
-
-Possible overload: effekt::println of type String => Unit
- Expected String but got Int.
-
-Possible overload: list::println of type List[Int] => Unit
- Expected String but got Int.
- Expected List[Int] but got String.
-
-Possible overload: effekt::println of type Byte => Unit
- Expected String but got Int.
- Expected Byte but got String.
-
-Possible overload: list::println of type List[String] => Unit
- Expected String but got Int.
- Expected List[String] but got String.
-
-Possible overload: list::println of type List[Double] => Unit
- Expected String but got Int.
- Expected List[Double] but got String.
-
-Possible overload: array::println of type Array[String] => Unit
- Expected String but got Int.
- Expected Array[String] but got String.
-
-Possible overload: effekt::println of type Ordering => Unit
- Expected String but got Int.
- Expected Ordering but got String.
-
-Possible overload: array::println of type Array[Bool] => Unit
- Expected String but got Int.
- Expected Array[Bool] but got String.
-
-Possible overload: effekt::println of type Unit => Unit
- Expected String but got Int.
- Expected Unit but got String.
-
-Possible overload: option::println of type Option[Int] => Unit
- Expected String but got Int.
- Expected Option[Int] but got String.
-
-Possible overload: option::println of type Option[Double] => Unit
- Expected String but got Int.
- Expected Option[Double] but got String.
-
-Possible overload: array::println of type Array[Double] => Unit
- Expected String but got Int.
- Expected Array[Double] but got String.
-
-Possible overload: effekt::println of type Double => Unit
- Expected String but got Int.
- Expected Double but got String.
-
-Possible overload: effekt::println of type Int => Unit
- Expected String but got Int.
- Expected Int but got String.
-
-Possible overload: option::println of type Option[Bool] => Unit
- Expected String but got Int.
- Expected Option[Bool] but got String.
-
- println("GET ${domain}/users/${user}/resource/${resourceId}")
```
</details>
Apart from that, the changes are really lightweight because of the early
desugaring in the parser.
I am looking forward to your feedback and ideas.
---------
Co-authored-by: Jiří Beneš <[email protected]>
Co-authored-by: Marvin <[email protected]>
Co-authored-by: Philipp Schuster <[email protected]>
Co-authored-by: Jonathan Brachthäuser <[email protected]>
0 commit comments