Skip to content

Commit

Permalink
adapt to reactives changes
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Apr 9, 2024
1 parent 1dac7dd commit b040493
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 32 deletions.
14 changes: 9 additions & 5 deletions Modules/Lore/src/main/scala/lore/dsl/BoundInteraction.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package lore.dsl

import rescala.Lul.dynamicTicket
import rescala.core.ReSource
import rescala.default.*
import reactives.Lul.dynamicTicket
import reactives.core.ReSource
import reactives.default.*
import reactives.operator.Interface.State as BundleState


import scala.quoted.{Expr, Quotes, Type}
import scala.reflect.ClassTag
Expand All @@ -11,7 +13,7 @@ def constructBoundInteractionWithRequires[ST <: Tuple, S <: Tuple, A](interactio
expr: Expr[(ST, A) => Boolean])
(using Quotes, Type[ST], Type[S], Type[A]): Expr[BoundInteraction[ST, S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(requires = $interaction.requires :+ Requires(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand All @@ -20,7 +22,7 @@ def constructBoundInteractionWithEnsures[ST <: Tuple, S <: Tuple, A](interaction
expr: Expr[(ST, A) => Boolean])
(using Quotes, Type[ST], Type[S], Type[A]): Expr[BoundInteraction[ST, S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(ensures = $interaction.ensures :+ Ensures(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand Down Expand Up @@ -63,7 +65,9 @@ case class BoundInteraction[ST <: Tuple, S <: Tuple, A] private[dsl](private[dsl
}

modifies.zip(res).asInstanceOf[Seq[(Var[Any], Any)]].map { case (source, v) => source.set(v) }
()
}

}

}
Expand Down
5 changes: 3 additions & 2 deletions Modules/Lore/src/main/scala/lore/dsl/DSL.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package lore.dsl

import rescala.core.{AdmissionTicket, ReSource, StaticTicket}
import rescala.default.*
import reactives.core.{AdmissionTicket, ReSource, StaticTicket}
import reactives.default.*
import reactives.operator.Interface.State as BundleState

import scala.quoted.*

Expand Down
8 changes: 4 additions & 4 deletions Modules/Lore/src/main/scala/lore/dsl/DSLTest.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package lore.dsl

import lore.dsl.Ex
import rescala.default.Var as Source
import rescala.default.Signal as Derived
import reactives.default.Var as Source
import reactives.default.Signal as Derived

object DSLTest {
@main
Expand All @@ -18,7 +18,7 @@ object DSLTest {
Invariant {
b.value < 25
}

val add10: BoundInteraction[Tuple1[Int], Tuple1[Source[Int]], Int] =
Interaction[Int, Int]
.requires[Int]((t, _) => t < 20)
Expand Down Expand Up @@ -73,4 +73,4 @@ class Test[S <: NonEmptyTuple, T <: NonEmptyTuple](val s: S, val t: T) {
val x: Test[Int *: Int *: (Int, Int), Box[Int] *: Box[Int] *: (Box[Int], Box[Int])] = Test((1, 2), (Box(1), Box(2)))
.append(3)
.append(4)
*/
*/
4 changes: 2 additions & 2 deletions Modules/Lore/src/main/scala/lore/dsl/Interaction.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lore.dsl

import lore.dsl.*
import rescala.default.{Var as Source, *}
import reactives.default.{Var as Source, *}

import scala.annotation.targetName

Expand Down Expand Up @@ -138,5 +138,5 @@ implicit object Ex {
BoundInteraction[(T1, T2, T3, T4, T5), (Source[T1], Source[T2], Source[T3], Source[T4], Source[T5]), A] =
BoundInteraction(m.requires, m.ensures, m.executes, (source1, source2, source3, source4, source5))
}

}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package lore.dsl

import rescala.core.ReSource
import rescala.default.BundleState
import reactives.core.ReSource
import reactives.operator.Interface.State as BundleState

import scala.quoted.{Expr, Quotes, Type}

def constructInteractionWithExecutesWithRequires[S <: Tuple, A](interaction: Expr[InteractionWithExecutes[S, A]],
expr: Expr[(S, A) => Boolean])
(using Quotes, Type[S], Type[A]): Expr[InteractionWithExecutes[S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(requires = $interaction.requires :+ Requires(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand All @@ -18,7 +18,7 @@ def constructInteractionWithExecutesWithEnsures[S <: Tuple, A](interaction: Expr
expr: Expr[(S, A) => Boolean])
(using Quotes, Type[S], Type[A]): Expr[InteractionWithExecutes[S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(ensures = $interaction.ensures :+ Ensures(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package lore.dsl

import rescala.core.ReSource
import rescala.default.*
import reactives.core.ReSource
import reactives.default.*
import reactives.operator.Interface.State as BundleState


import scala.quoted.{Expr, Quotes, Type}

def constructInteractionWithModifiesWithRequires[ST <: Tuple, S <: Tuple, A](interaction: Expr[InteractionWithModifies[ST, S, A]],
expr: Expr[(ST, A) => Boolean])
(using Quotes, Type[ST], Type[S], Type[A]): Expr[InteractionWithModifies[ST, S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(requires = $interaction.requires :+ Requires(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand All @@ -18,7 +20,7 @@ def constructInteractionWithModifiesWithEnsures[ST <: Tuple, S <: Tuple, A](inte
expr: Expr[(ST, A) => Boolean])
(using Quotes, Type[ST], Type[S], Type[A]): Expr[InteractionWithModifies[ST, S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(ST, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

val newEns = Ensures(inputs, fun, ${ showPredicateCode(expr) })

Expand Down
4 changes: 2 additions & 2 deletions Modules/Lore/src/main/scala/lore/dsl/Invariant.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lore.dsl

import rescala.core.CreationTicket
import rescala.default.*
import reactives.core.CreationTicket
import reactives.default.*

import scala.quoted.*

Expand Down
9 changes: 5 additions & 4 deletions Modules/Lore/src/main/scala/lore/dsl/UnboundInteraction.scala
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package lore.dsl

import rescala.core.ReSource
import rescala.default.BundleState
import reactives.core.ReSource
import reactives.operator.Interface.State as BundleState


import scala.quoted.{Expr, Quotes, Type}

def constructUnboundInteractionWithRequires[S <: Tuple, A](interaction: Expr[UnboundInteraction[S, A]],
expr: Expr[(S, A) => Boolean])
(using Quotes, Type[S], Type[A]): Expr[UnboundInteraction[S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(requires = $interaction.requires :+ Requires(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand All @@ -18,7 +19,7 @@ def constructUnboundInteractionWithEnsures[S <: Tuple, A](interaction: Expr[Unbo
expr: Expr[(S, A) => Boolean])
(using Quotes, Type[S], Type[A]): Expr[UnboundInteraction[S, A]] = '{
val (inputs, fun, isStatic) =
rescala.macros.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], rescala.core.StaticTicket[BundleState], true]($expr)
reactives.macros.MacroLegos.getDependencies[(S, A) => Boolean, ReSource.of[BundleState], reactives.core.StaticTicket[BundleState], true]($expr)

$interaction.copy(ensures = $interaction.ensures :+ Ensures(inputs, fun, ${ showPredicateCode(expr) }))
}
Expand Down
10 changes: 6 additions & 4 deletions Modules/Lore/src/main/scala/rescala/Lul.scala
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package rescala
package reactives

import reactives.core.{AdmissionTicket, ReevTicket, StaticTicket}
import reactives.default.*
import reactives.scheduler.Twoversion
import reactives.operator.Interface.State as BundleState

import rescala.core.{AdmissionTicket, ReevTicket, StaticTicket}
import rescala.default.*
import rescala.scheduler.Twoversion

package object Lul extends Twoversion {
def dynamicTicket(implicit at: AdmissionTicket[BundleState]): StaticTicket[BundleState] =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lore.calendar

import lore.dsl.*
import rescala.default.{Signal as Derived, Var as Source}
import reactives.default.{Signal as Derived, Var as Source}

import scala.collection.immutable.Set as AWSet

Expand Down

0 comments on commit b040493

Please sign in to comment.