Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added appropriate instances for Scala 2 for some but not all derivers #299

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add ZIO integration for reading MorphirIR from file
DamianReeves committed Aug 2, 2023

Verified

This commit was signed with the committer’s verified signature.
DamianReeves Damian Reeves
commit 3a3f14198e4b95760c3025793eb6898a06e1eb38
Original file line number Diff line number Diff line change
@@ -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}

@@ -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
@@ -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)
Loading