Skip to content

Commit

Permalink
Added appropriate instances for Scala 2 for some but not all derivers (
Browse files Browse the repository at this point in the history
…#299)

* Added appropriate instances for Scala 2 for some but not all derivers

* Add evaluator-tests as a yarn workspace

* Add ZIO integration for reading MorphirIR from file

* Formatting

* Remove un-needed tests
  • Loading branch information
DamianReeves authored Aug 2, 2023
1 parent 20e64d4 commit a84c979
Show file tree
Hide file tree
Showing 52 changed files with 1,232 additions and 442 deletions.
504 changes: 492 additions & 12 deletions .pnp.cjs

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 7 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,12 @@ trait MorphirModule extends Cross.Module[String] with CrossPlatform { morphir =>

object jvm extends Shared with MorphirJVMModule {
object test extends ScalaTests with TestModule.ZioTest {
def ivyDeps = Agg(Deps.dev.zio.`zio-test`, Deps.dev.zio.`zio-test-sbt`)
def ivyDeps = Agg(
Deps.com.lihaoyi.`os-lib`,
Deps.com.lihaoyi.sourcecode,
Deps.dev.zio.`zio-test`,
Deps.dev.zio.`zio-test-sbt`
)
def moduleDeps = super.moduleDeps ++ Agg(testing.zio.jvm)
}
}
Expand All @@ -460,6 +465,7 @@ trait MorphirModule extends Cross.Module[String] with CrossPlatform { morphir =>
object test extends ScalaJSTests with TestModule.ZioTest {
def ivyDeps = Agg(Deps.dev.zio.`zio-test`, Deps.dev.zio.`zio-test-sbt`)
def moduleDeps = super.moduleDeps ++ Agg(testing.zio.js)
def moduleKind = ModuleKind.CommonJSModule
}
}

Expand Down
10 changes: 10 additions & 0 deletions examples/morphir-elm-projects/evaluator-tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"name": "morphir-scala-evaluator-tests",
"private": true,
"devDependencies": {
"morphir-elm": "2.80.0"
},
"scripts": {
"make": "morphir-elm make -f"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.finos.morphir.ir.MorphirIRFile
import org.finos.morphir.runtime.MorphirRuntime
import scala.io.Source
import zio.json.*
import zio.*
import org.finos.morphir.ir.json.MorphirJsonSupport.*
import org.finos.morphir.runtime.quick.{EvaluatorQuick, Store}

Expand Down Expand Up @@ -42,4 +43,12 @@ trait EvaluationLibraryPlatformSpecific {
.getOrElse(throw new Exception(s"Failed to load $fileName as distribution"))
.distribution
}

def loadDistributionFromFileZIO(fileName: String): Task[Distribution] =
for {
fileContents <- ZIO.readFile(fileName)
morphirIRFile <- ZIO.fromEither(fileContents.fromJson[MorphirIRFile])
.mapError(MorphirIRDecodingError(_))
} yield morphirIRFile.distribution

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@ package org.finos.morphir.runtime

sealed abstract class MorphirRuntimeError(message: String) extends Exception(message)

case class DerivationError(message: String) extends MorphirRuntimeError(message)
case class DatamodelToIrError(message: String) extends MorphirRuntimeError(message)
final case class DerivationError(message: String) extends MorphirRuntimeError(message)
final case class DatamodelToIrError(message: String) extends MorphirRuntimeError(message)
final case class MorphirIRDecodingError(message: String) extends MorphirRuntimeError(message)

sealed abstract class EvaluationError(message: String) extends MorphirRuntimeError(message)
sealed abstract class TypeError(message: String) extends MorphirRuntimeError(message)

case class IrToDatamodelError(message: String) extends EvaluationError(message)
case class MissingField(message: String) extends EvaluationError(message)
case class UnexpectedType(message: String) extends EvaluationError(message)
case class UnmatchedPattern(message: String) extends EvaluationError(message)
case class FunctionWithoutParameters(message: String) extends EvaluationError(message)
case class VariableNotFound(message: String) extends EvaluationError(message)
case class DefinitionNotFound(message: String) extends EvaluationError(message)
case class SpecificationNotFound(message: String) extends EvaluationError(message)
case class ConstructorNotFound(message: String) extends EvaluationError(message)
case class TypeNotFound(message: String) extends EvaluationError(message)
case class ResultDoesNotMatchType(message: String) extends EvaluationError(message)
case class FunctionReturnedToTopLevel(message: String) extends EvaluationError(message)
case class UnsupportedTypeParameter(message: String) extends EvaluationError(message)
case class UnsupportedType(message: String) extends EvaluationError(message)
case class NotImplemented(message: String) extends EvaluationError(message)
final case class IrToDatamodelError(message: String) extends EvaluationError(message)
final case class MissingField(message: String) extends EvaluationError(message)
final case class UnexpectedType(message: String) extends EvaluationError(message)
final case class UnmatchedPattern(message: String) extends EvaluationError(message)
final case class FunctionWithoutParameters(message: String) extends EvaluationError(message)
final case class VariableNotFound(message: String) extends EvaluationError(message)
final case class DefinitionNotFound(message: String) extends EvaluationError(message)
final case class SpecificationNotFound(message: String) extends EvaluationError(message)
final case class ConstructorNotFound(message: String) extends EvaluationError(message)
final case class TypeNotFound(message: String) extends EvaluationError(message)
final case class ResultDoesNotMatchType(message: String) extends EvaluationError(message)
final case class FunctionReturnedToTopLevel(message: String) extends EvaluationError(message)
final case class UnsupportedTypeParameter(message: String) extends EvaluationError(message)
final case class UnsupportedType(message: String) extends EvaluationError(message)
final case class NotImplemented(message: String) extends EvaluationError(message)

case class TooManyArgs(message: String) extends EvaluationError(message)
final case class TooManyArgs(message: String) extends EvaluationError(message)
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Utils.*
import org.finos.morphir.ir.distribution.Distribution
import org.finos.morphir.ir.conversion.*
import org.finos.morphir.datamodel.Util.*
import org.finos.morphir.datamodel.{:: as _, *}
import org.finos.morphir.datamodel.*

//TODO: Specify "Either" on lower level
trait TypedMorphirRuntime extends MorphirRuntime[Either, scala.Unit, UType] {
Expand Down
Loading

0 comments on commit a84c979

Please sign in to comment.