Skip to content

Instantly share code, notes, and snippets.

@DamianReeves
Last active January 4, 2023 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamianReeves/252e1daa4c821b885318cb616c366d4b to your computer and use it in GitHub Desktop.
Save DamianReeves/252e1daa4c821b885318cb616c366d4b to your computer and use it in GitHub Desktop.
Morphir Macro ideas
trait PersonModule {
trait Person { def name: String; def age: Int }
}
trait ModuleDef[T] {
val value: T
}
// val myModule: ModuleDef[PersonModule] =
// new ModuleDef[PersonModule] {
// val value: PersonModule = new PersonModule {}
/// }
val myModule: ModuleDef[PersonModule] = moduleDef[PersonModule]
case class Person(name: String, age: Int) extends myModule.MyPerson
@Module
trait Math {
@Native(Morphir.Add)
def add(a: Int, b: Int)
}
@Module
trait AddressModule {
case class Address(street: String, zip: Int)
def addZips(a: Address, b: Address) = a.zip + b.zip
}
@Module
trait PersonModule {
@ImportModule
val addressModule: AddressModule
case class Person(def name: String; address: addressModule.Address)
@Import Module
val mathModule: Math
def addAgeAndZip(p: Person, a: Address) = mathModule.add(a.age, a.zip)
}
val packageBundle: PackageBundle[PersonModule] = makePackageBundle[PersonModule]
// compile with yPreserveTrees
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment