-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Working towards making Module module match expected shape * Re-organizing things to closer match morphir-elm * Testing reorganization * Added tests for Name * Added PackageSpecFor and ModuleSpecFor * Rename IR to MorphirIR * Cleanup code organization of MorphirIR * Added some additional things to the Type module * Added transform operators. Co-authored-by: Adam Fraser <[email protected]> * Power up the Type * Rename ir file * formatting * Unused import * Fix tests * Unused import Co-authored-by: Adam Fraser <[email protected]>
- Loading branch information
1 parent
669ca2d
commit 3f66737
Showing
25 changed files
with
1,081 additions
and
631 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package zio.morphir | ||
|
||
import zio.morphir.ir._ | ||
|
||
final case class IR(valueSpecifications: Map[FQName, ???]) | ||
object IR {} |
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
14 changes: 14 additions & 0 deletions
14
morphir-ir/shared/src/main/scala/zio/morphir/ir/FQName.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 zio.morphir.ir | ||
|
||
final case class FQName(packagePath: PackageName, modulePath: ModulePath, localName: Name) | ||
|
||
object FQName { | ||
def apply(packagePath: Path, modulePath: Path, localName: Name): FQName = | ||
FQName(PackageName(packagePath), ModulePath(modulePath), localName) | ||
|
||
val fqName: Path => Path => Name => FQName = packagePath => | ||
modulePath => localName => FQName(PackageName(packagePath), ModulePath(modulePath), localName) | ||
|
||
/** Get the package path part of a fully-qualified name. */ | ||
def getPackagePath(fqName: FQName): Path = fqName.packagePath.toPath | ||
} |
12 changes: 12 additions & 0 deletions
12
morphir-ir/shared/src/main/scala/zio/morphir/ir/Literal.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,12 @@ | ||
package zio.morphir.ir | ||
|
||
sealed trait Literal[+A] { | ||
def value: A | ||
} | ||
object Literal { | ||
final case class Bool(value: scala.Boolean) extends Literal[scala.Boolean] | ||
final case class Char(value: scala.Char) extends Literal[scala.Char] | ||
final case class String(value: java.lang.String) extends Literal[java.lang.String] | ||
final case class WholeNumber(value: java.math.BigInteger) extends Literal[java.math.BigInteger] | ||
final case class Float(value: java.math.BigDecimal) extends Literal[java.math.BigDecimal] | ||
} |
45 changes: 45 additions & 0 deletions
45
morphir-ir/shared/src/main/scala/zio/morphir/ir/Module.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,45 @@ | ||
package zio.morphir.ir | ||
|
||
object Module { | ||
|
||
type Definition[+Annotations] = MorphirIR.ModuleDefinition[Annotations] | ||
val Definition = MorphirIR.ModuleDefinition | ||
|
||
type Specification[+Annotations] = MorphirIR.ModuleSpecification[Annotations] | ||
val Specification = MorphirIR.ModuleSpecification | ||
|
||
lazy val emptyDefinition: Definition[Any] = Definition.empty | ||
|
||
lazy val emptySpecification: Specification[Any] = Specification.empty | ||
|
||
final case class ModuleName(namespace: Path, localName: Name) { | ||
lazy val toPath = namespace / localName | ||
} | ||
|
||
final case class ModulePath(toPath: Path) | ||
|
||
final case class QualifiedModuleName(packageName: Path, module: Path) { | ||
lazy val toPath = packageName / module | ||
} | ||
|
||
} | ||
|
||
trait ModuleSpecFor[A] { | ||
import Module.* | ||
|
||
def module: ModuleName | ||
def spec: Specification[Any] | ||
} | ||
|
||
object ModuleSpecFor { | ||
import Module.* | ||
|
||
/** Summon the module specification for the given module/type. */ | ||
def apply[A](implicit specFor: ModuleSpecFor[A]): ModuleSpecFor[A] = specFor | ||
|
||
def make[A](name: ModuleName)(moduleSpec: Specification[Any]): ModuleSpecFor[A] = | ||
new ModuleSpecFor[A] { | ||
val module = name | ||
val spec = moduleSpec | ||
} | ||
} |
Oops, something went wrong.