Repository: effekt-lang/effekt (scala)

Issue:
Add 'stringbuffer' to prelude
It's annoying to explicitly `import stringbuffer` every time I want to use the standard string interpolation.
After #1116 is merged, could we also try to incorporate this tiny module somewhere else (perhaps into the `string` module?)

I'd also be fine integrating it further into the `stream` module.

If we really care about backwards compatibility, we could leave the `stringbuffer` module just empty for a few versions.

Pull request:
Fixes #1131

Patch:
diff --git a/effekt/js/src/main/scala/effekt/EffektConfig.scala b/effekt/js/src/main/scala/effekt/EffektConfig.scala
index 903c158a7..8b50b1eab 100644
--- a/effekt/js/src/main/scala/effekt/EffektConfig.scala
+++ b/effekt/js/src/main/scala/effekt/EffektConfig.scala
@@ -27,6 +27,7 @@ trait EffektConfig {
     "array",
     "char",
     "bytearray",
+    "stringbuffer",
     "string",
     "ref"
   )
diff --git a/effekt/jvm/src/main/scala/effekt/Runner.scala b/effekt/jvm/src/main/scala/effekt/Runner.scala
index 560033a5d..056b86b39 100644
--- a/effekt/jvm/src/main/scala/effekt/Runner.scala
+++ b/effekt/jvm/src/main/scala/effekt/Runner.scala
@@ -43,7 +43,7 @@ trait Runner[Executable] {
    * if module A depends on module B, then B should come before A.
    * - Furthermore, each module mentioned here must import the `effekt` module as its first import.
    */
-  def prelude: List[String] = List("effekt", "option", "stream", "list", "result", "exception", "array", "char", "bytearray", "string", "ref")
+  def prelude: List[String] = List("effekt", "option", "stream", "list", "result", "exception", "array", "char", "bytearray", "stringbuffer", "string", "ref")
 
   /**
    * Creates a OS-specific script file that will execute the command when executed,
diff --git a/examples/benchmarks/other/nbe.effekt b/examples/benchmarks/other/nbe.effekt
index e0791105b..8e862a23d 100644
--- a/examples/benchmarks/other/nbe.effekt
+++ b/examples/benchmarks/other/nbe.effekt
@@ -6,7 +6,6 @@ import io
 import map
 import stream
 import process
-import stringbuffer
 
 type Name = Int
 
diff --git a/examples/pos/string_interpolation.effekt b/examples/pos/string_interpolation.effekt
index b5fe1e529..203ff0506 100644
--- a/examples/pos/string_interpolation.effekt
+++ b/examples/pos/string_interpolation.effekt
@@ -1,5 +1,3 @@
-import stringbuffer
-
 type Expr {
   Var(id: String)
   Abs(param: String, body: Expr)
diff --git a/examples/stdlib/array/binarySearch.effekt b/examples/stdlib/array/binarySearch.effekt
index 35e6259c3..5783afa26 100644
--- a/examples/stdlib/array/binarySearch.effekt
+++ b/examples/stdlib/array/binarySearch.effekt
@@ -1,5 +1,3 @@
-import stringbuffer
-
 def find(arr: Array[Int], elem: Int): Unit = {
   val optIdx = arr.binarySearch(elem) { compareInt }
   optIdx match {
diff --git a/libraries/common/stringbuffer.effekt b/libraries/common/stringbuffer.effekt
index dd4daac2d..47d2061cf 100644
--- a/libraries/common/stringbuffer.effekt
+++ b/libraries/common/stringbuffer.effekt
@@ -1,5 +1,6 @@
 module stringbuffer
 
+import effekt
 import bytearray
 
 interface StringBuffer {


Test patch:
diff --git a/effekt/jvm/src/test/scala/effekt/LSPTests.scala b/effekt/jvm/src/test/scala/effekt/LSPTests.scala
index 784c2e55d..018e744b4 100644
--- a/effekt/jvm/src/test/scala/effekt/LSPTests.scala
+++ b/effekt/jvm/src/test/scala/effekt/LSPTests.scala
@@ -1380,7 +1380,7 @@ class LSPTests extends FunSuite {
       val expectedIRContents =
         raw"""ModuleDecl(
              |  test,
-             |  List(effekt, option, stream, list, result, exception, array, char, bytearray, string, ref),
+             |  List(effekt, option, stream, list, result, exception, array, char, bytearray, stringbuffer, string, ref),
              |  Nil,
              |  Nil,
              |  List(