-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding IR - #75 * Adding Package related IR types * issue-94: add tuple to sdk (#98) * issue-94: add tuple to sdk * issue-94: run formatter * Finishing up modeling of morphir IR in Scala 3 * Move IR into morphir-ir Co-authored-by: willms2021 <[email protected]>
- Loading branch information
1 parent
14cc17b
commit dd2d4c7
Showing
36 changed files
with
556 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.9.5 | ||
0.9.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import sbt.Keys._ | ||
import sbt._ | ||
|
||
resolvers ++= Seq( | ||
Resolver.mavenLocal, | ||
Resolver.sonatypeRepo("releases"), | ||
Resolver.sonatypeRepo("snapshots"), | ||
Resolver.jcenterRepo | ||
) | ||
|
||
lazy val root = (project in file(".")) | ||
.settings( | ||
commonSettings, | ||
libraryDependencies ++= Dependencies.zioCommonDeps, | ||
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")) | ||
) | ||
.aggregate( | ||
morphirIR | ||
) | ||
|
||
lazy val commonSettings = Seq( | ||
name := "morphir-ir", | ||
version := "0.1.0", | ||
scalacOptions ++= Seq( | ||
"-deprecation", | ||
"-language:postfixOps", | ||
"-Ykind-projector", | ||
"-Yexplicit-nulls", | ||
"-source", | ||
"future", | ||
"-Xfatal-warnings" | ||
) ++ Seq("-rewrite", "-indent"), | ||
scalaVersion := "3.0.0" | ||
) | ||
|
||
lazy val morphirIR = project | ||
.in(file("./morphir-ir")) | ||
.settings( | ||
name := "morphir-ir", | ||
version := "0.1.0", | ||
scalacOptions ++= Seq( | ||
"-language:postfixOps", | ||
"-Ykind-projector", | ||
"-Yexplicit-nulls", | ||
"-source", | ||
"future", | ||
"-Xfatal-warnings" | ||
), | ||
libraryDependencies ++= Dependencies.zioCommonDeps, | ||
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework")), | ||
scalaVersion := "3.0.0" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
morphir-ir/src/main/scala/org/finos/morphir/ir/AccessControlled.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class AccessControlled[+A](access: Access, value: A) { | ||
|
||
def isPrivate: Boolean = access == Access.Private | ||
def isPublic: Boolean = access == Access.Public | ||
|
||
def map[B](f: A => B): AccessControlled[B] = | ||
copy(value = f(value)) | ||
|
||
def withPrivateAccess: A = access match { | ||
case Access.Public => value | ||
case Access.Private => value | ||
} | ||
|
||
def withPublicAccess: Option[A] = access match { | ||
case Access.Public => Some(value) | ||
case Access.Private => None | ||
} | ||
} | ||
|
||
enum Access: | ||
case Public | ||
case Private |
14 changes: 14 additions & 0 deletions
14
morphir-ir/src/main/scala/org/finos/morphir/ir/Constructors.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package org.finos.morphir.ir | ||
import scala.collection.immutable.ListMap | ||
|
||
/** | ||
* Constructors in a dictionary keyed by their name. The values are the argument types for each | ||
* constructor | ||
*/ | ||
final case class TypeConstructors[+A](lookup: ListMap[Name, List[(Name, Type[A])]]): | ||
def transform[B](f: A => B): TypeConstructors[B] = | ||
TypeConstructors( | ||
lookup.map((name, args) => | ||
(name, args.map((argName, argType) => (argName, argType.transform(f)))) | ||
) | ||
) |
4 changes: 4 additions & 0 deletions
4
morphir-ir/src/main/scala/org/finos/morphir/ir/Distribution.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package org.finos.morphir.ir | ||
|
||
enum Distribution: | ||
case Library(packageName: PackageName) |
7 changes: 7 additions & 0 deletions
7
morphir-ir/src/main/scala/org/finos/morphir/ir/Documented.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.finos.morphir.ir | ||
|
||
/** | ||
* Type that represents a documented value. | ||
*/ | ||
final case class Documented[+A](doc: String, value: A): | ||
def map[B](f: A => B): Documented[B] = copy(value = f(value)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.finos.morphir.ir | ||
|
||
case class FQName( | ||
packagePath: Path, | ||
modulePath: Path, | ||
localName: Name | ||
) |
10 changes: 10 additions & 0 deletions
10
morphir-ir/src/main/scala/org/finos/morphir/ir/Field.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class Field[+A](name: String, fieldType: Type[A]): | ||
def mapAttributes[B](f: A => B): Field[B] = | ||
Field(name = name, fieldType = fieldType.transform(f)) | ||
|
||
object FieldList: | ||
extension [A](self: List[Field[A]]) | ||
def mapAttributes[B](f: A => B): List[Field[B]] = | ||
self.map(field => field.mapAttributes(f)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.finos.morphir.ir | ||
|
||
enum Lit: | ||
case Bool(value: Boolean) | ||
case Char(value: scala.Char) | ||
case Str(value: String) | ||
case Int(value: scala.Int) //TODO: Maybe BigInt | ||
case Float(value: scala.Double) |
22 changes: 22 additions & 0 deletions
22
morphir-ir/src/main/scala/org/finos/morphir/ir/ModuleDefinition.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.finos.morphir.ir | ||
import scala.collection.immutable.ListMap | ||
|
||
/** | ||
* Type that represents a module definition. A module definition contains all the details including | ||
* implementation and private types and values. | ||
* | ||
* A module contains types and values which is represented by two field in this type: | ||
* - types: a map of local name to access controlled, documented type specification. | ||
* - values: a map of local name to access controlled value specification. | ||
*/ | ||
final case class ModuleDefinition[+TA, +VA]( | ||
types: ListMap[Name, AccessControlled[Documented[TypeDefinition[TA]]]], | ||
values: ListMap[Name, AccessControlled[ValueDefinition[TA, VA]]] | ||
): | ||
|
||
def lookupValueDefinition(name: Name): Option[ValueDefinition[TA, VA]] = | ||
values get name map (_.withPrivateAccess) | ||
|
||
object ModuleDefinition: | ||
def empty[TA, VA]: ModuleDefinition[TA, VA] = | ||
ModuleDefinition[TA, VA](ListMap.empty, ListMap.empty) |
3 changes: 3 additions & 0 deletions
3
morphir-ir/src/main/scala/org/finos/morphir/ir/ModuleName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class ModuleName(path: List[Name]) |
7 changes: 7 additions & 0 deletions
7
morphir-ir/src/main/scala/org/finos/morphir/ir/ModuleSpecification.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.finos.morphir.ir | ||
import scala.collection.immutable.ListMap | ||
|
||
final case class ModuleSpecification[+A]( | ||
types: ListMap[Name, Documented[TypeSpecification[A]]], | ||
values: ListMap[Name, ValueSpecification[A]] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class Name(name: List[String]) |
9 changes: 9 additions & 0 deletions
9
morphir-ir/src/main/scala/org/finos/morphir/ir/PackageDefinition.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.finos.morphir.ir | ||
|
||
import scala.collection.immutable.ListMap | ||
|
||
final case class PackageDefinition[TA, VA]( | ||
modules: ListMap[ModuleName, AccessControlled[ModuleDefinition[TA, VA]]] | ||
) | ||
object PackageDefinition: | ||
val empty: PackageDefinition[Unit, Unit] = PackageDefinition[Unit, Unit](ListMap.empty) |
3 changes: 3 additions & 0 deletions
3
morphir-ir/src/main/scala/org/finos/morphir/ir/PackageName.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class PackageName(path: List[Name]) |
8 changes: 8 additions & 0 deletions
8
morphir-ir/src/main/scala/org/finos/morphir/ir/PackageSpecification.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.finos.morphir.ir | ||
import scala.collection.immutable.ListMap | ||
|
||
final case class PackageSpecification[+A](modules: ListMap[ModuleName, ModuleSpecification[A]]) | ||
|
||
object PackageSpecification: | ||
def empty[A]: PackageSpecification[A] = | ||
PackageSpecification[A](ListMap.empty) |
7 changes: 7 additions & 0 deletions
7
morphir-ir/src/main/scala/org/finos/morphir/ir/ParameterInfo.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class ParameterInfo[+TA, +VA]( | ||
name: Name, | ||
annotations: VA, | ||
parameterType: Type[TA] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
package org.finos.morphir.ir | ||
|
||
final case class Path(path: List[Name]) |
13 changes: 13 additions & 0 deletions
13
morphir-ir/src/main/scala/org/finos/morphir/ir/Pattern.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.finos.morphir.ir | ||
|
||
case class Pattern[+A](ann: A, details: PatternDetails[A]) | ||
|
||
enum PatternDetails[+A]: | ||
case Wildcard | ||
case As(pattern: Pattern[A], name: Name) | ||
case Tuple(components: List[Pattern[A]]) | ||
case Constructor(fqName: FQName, parameters: List[Pattern[A]]) | ||
case EmptyList | ||
case HeadTail(head: Pattern[A], tail: Pattern[A]) | ||
case Literal(literal: Lit) | ||
case Unit |
Oops, something went wrong.