Repository: rcardin/raise4s
Pull request #42 (2024-05-31 12:58:37)

Extracted a `core` module
Extracted a `core` module.

The library now has the following name:

```sbt
libraryDependencies += "in.rcard.raise4s" %% "core" % "0.0.6"
```


Patch:
diff --git a/README.md b/README.md
index b0c3b9c..9c64973 100644
--- a/README.md
+++ b/README.md
@@ -12,12 +12,12 @@ Porting of the Raise DSL from the Arrow Kt Kotlin library
 The library is available on Maven Central. To use it, add the following dependency to your `build.sbt` files:
 
 ```sbt
-libraryDependencies += "in.rcard" %% "raise4s" % "0.0.5"
+libraryDependencies += "in.rcard.raise4s" %% "core" % "0.0.6"
 ```
 
 The library is only available for Scala 3.
 
-## Usage
+## Usage 
 
 ### The `Raise` DSL in Scala
 
diff --git a/build.sbt b/build.sbt
index c7894f5..83690b6 100644
--- a/build.sbt
+++ b/build.sbt
@@ -1,25 +1,52 @@
-inThisBuild(List(
-  organization := "in.rcard",
-  homepage := Some(url("https://github.com/rcardin")),
-  // Alternatively License.Apache2 see https://github.com/sbt/librarymanagement/blob/develop/core/src/main/scala/sbt/librarymanagement/License.scala
-  licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
-  developers := List(
-    Developer(
-      "rcardin",
-      "Riccardo Cardin",
-      "riccardo DOT cardin AT gmail.com",
-      url("https://github.com/rcardin/raise4s")
+inThisBuild(
+  List(
+    organization := "in.rcard.raise4s",
+    homepage     := Some(url("https://github.com/rcardin")),
+    // Alternatively License.Apache2 see https://github.com/sbt/librarymanagement/blob/develop/core/src/main/scala/sbt/librarymanagement/License.scala
+    licenses := List("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0")),
+    developers := List(
+      Developer(
+        "rcardin",
+        "Riccardo Cardin",
+        "riccardo DOT cardin AT gmail.com",
+        url("https://github.com/rcardin/raise4s")
+      )
     )
   )
-))
+)
 
 ThisBuild / sonatypeCredentialHost := "s01.oss.sonatype.org"
-sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
+sonatypeRepository                 := "https://s01.oss.sonatype.org/service/local"
+sonatypeProfileName                := "in.rcard"
 
 name := "raise4s"
 //version := "0.0.1-SNAPSHOT"
-scalaVersion := "3.4.2"
+val scala3Version = "3.4.2"
+scalaVersion := scala3Version
 
 libraryDependencies ++= Seq(
   "org.scalatest" %% "scalatest" % "3.2.18" % Test
-)
\ No newline at end of file
+)
+
+lazy val core = project
+  .settings(
+    name         := "core",
+    scalaVersion := scala3Version,
+    libraryDependencies ++= commonDependencies
+  )
+
+lazy val raise4s = (project in file("."))
+  .aggregate(core)
+  .settings(
+    scalaVersion := scala3Version
+  )
+
+lazy val dependencies =
+  new {
+    val scalatestVersion = "3.2.17"
+    val scalatest        = "org.scalatest" %% "scalatest" % scalatestVersion
+  }
+
+lazy val commonDependencies = Seq(
+  dependencies.scalatest % Test
+)
diff --git a/src/main/scala/in/rcard/raise4s/Bind.scala b/core/src/main/scala/in/rcard/raise4s/Bind.scala
similarity index 100%
rename from src/main/scala/in/rcard/raise4s/Bind.scala
rename to core/src/main/scala/in/rcard/raise4s/Bind.scala
diff --git a/src/main/scala/in/rcard/raise4s/Builders.scala b/core/src/main/scala/in/rcard/raise4s/Builders.scala
similarity index 97%
rename from src/main/scala/in/rcard/raise4s/Builders.scala
rename to core/src/main/scala/in/rcard/raise4s/Builders.scala
index b75c8ec..4f83aa9 100644
--- a/src/main/scala/in/rcard/raise4s/Builders.scala
+++ b/core/src/main/scala/in/rcard/raise4s/Builders.scala
@@ -1,6 +1,6 @@
 package in.rcard.raise4s
 
-import in.rcard.raise4s.Bind.value
+import Bind.value
 
 import scala.util.{Failure, Success, Try}
 
diff --git a/src/main/scala/in/rcard/raise4s/Fold.scala b/core/src/main/scala/in/rcard/raise4s/Fold.scala
similarity index 100%
rename from src/main/scala/in/rcard/raise4s/Fold.scala
rename to core/src/main/scala/in/rcard/raise4s/Fold.scala
diff --git a/src/main/scala/in/rcard/raise4s/Raise.scala b/core/src/main/scala/in/rcard/raise4s/Raise.scala
similarity index 99%
rename from src/main/scala/in/rcard/raise4s/Raise.scala
rename to core/src/main/scala/in/rcard/raise4s/Raise.scala
index fa6713a..03ca151 100644
--- a/src/main/scala/in/rcard/raise4s/Raise.scala
+++ b/core/src/main/scala/in/rcard/raise4s/Raise.scala
@@ -1,5 +1,8 @@
 package in.rcard.raise4s
 
+import in.rcard.raise4s
+
+import java.lang.Runtime
 import scala.annotation.targetName
 import scala.util.Try
 import scala.util.control.{ControlThrowable, NoStackTrace, NonFatal}
@@ -1696,5 +1699,5 @@ object Raise {
     * @return
     *   The result of the execution of the `block` lambda or the logical error
     */
-  def run[Error, A](block: Raise[Error] ?=> A): Error | A = Runtime._run(block)
+  def run[Error, A](block: Raise[Error] ?=> A): Error | A = raise4s.Runtime._run(block)
 }


Test patch:
diff --git a/src/main/scala/in/rcard/raise4s/Runtime.scala b/core/src/main/scala/in/rcard/raise4s/Runtime.scala
similarity index 100%
rename from src/main/scala/in/rcard/raise4s/Runtime.scala
rename to core/src/main/scala/in/rcard/raise4s/Runtime.scala
diff --git a/src/test/scala/in/rcard/raise4s/BindTest.scala b/core/src/test/scala/in/rcard/raise4s/BindTest.scala
similarity index 100%
rename from src/test/scala/in/rcard/raise4s/BindTest.scala
rename to core/src/test/scala/in/rcard/raise4s/BindTest.scala
diff --git a/src/test/scala/in/rcard/raise4s/BuildersSpec.scala b/core/src/test/scala/in/rcard/raise4s/BuildersSpec.scala
similarity index 100%
rename from src/test/scala/in/rcard/raise4s/BuildersSpec.scala
rename to core/src/test/scala/in/rcard/raise4s/BuildersSpec.scala
diff --git a/src/test/scala/in/rcard/raise4s/FoldSpec.scala b/core/src/test/scala/in/rcard/raise4s/FoldSpec.scala
similarity index 100%
rename from src/test/scala/in/rcard/raise4s/FoldSpec.scala
rename to core/src/test/scala/in/rcard/raise4s/FoldSpec.scala
diff --git a/src/test/scala/in/rcard/raise4s/RaiseSpec.scala b/core/src/test/scala/in/rcard/raise4s/RaiseSpec.scala
similarity index 100%
rename from src/test/scala/in/rcard/raise4s/RaiseSpec.scala
rename to core/src/test/scala/in/rcard/raise4s/RaiseSpec.scala
diff --git a/src/test/scala/in/rcard/raise4s/RuntimeSpec.scala b/core/src/test/scala/in/rcard/raise4s/RuntimeSpec.scala
similarity index 81%
rename from src/test/scala/in/rcard/raise4s/RuntimeSpec.scala
rename to core/src/test/scala/in/rcard/raise4s/RuntimeSpec.scala
index 512a0af..5d77844 100644
--- a/src/test/scala/in/rcard/raise4s/RuntimeSpec.scala
+++ b/core/src/test/scala/in/rcard/raise4s/RuntimeSpec.scala
@@ -6,20 +6,20 @@ import org.scalatest.matchers.should.Matchers
 class RuntimeSpec extends AnyFlatSpec with Matchers {
   "Raise.run" should "return the happy path value is no error was risen" in {
     val happyPathBlock: Int raises String = 42
-    val result: String | Int = Runtime._run(happyPathBlock)
+    val result: String | Int = Raise.run(happyPathBlock)
     result should be(42)
   }
 
   it should "return the error value if an error was risen" in {
     val errorBlock: Int raises String = Raise.raise("error")
-    val result: String | Int = Runtime._run(errorBlock)
+    val result: String | Int = Raise.run(errorBlock)
     result should be("error")
   }
 
   it should "be transparent to any thrown exception" in {
     val exceptionBlock: Int raises String = throw new RuntimeException("error")
     assertThrows[RuntimeException] {
-      Runtime._run(exceptionBlock)
+      Raise.run(exceptionBlock)
     }
   }
 }