conner
11/27/2023, 9:58 PMinikio
is exactly part of arrow (I can delete if this is an inappropriate venue), but my question should be generic to any tagless-style interpreter -- is there a way to compose interpreters when using the suspend
approach? I might also be misunderstanding the "right" way to do this.
Using the inikio
example:
tailrec fun <A> Casino<A>.execute(): A =
when(this) {
is Done -> result
is FlipCoin -> next(Random.nextFlipOutcome()).execute()
}
What if I e.g. wanted to log something whenever FlipCoin
is interpreted?Alejandro Serrano.Mena
11/28/2023, 8:16 AMtailrec fun <A> OtherInterpreter.execute(casino: Casino<A>): A = when (this) {
is Done -> result
is FlipCoin -> {
val outcome = Random.nextFlipOutcome()
operationFromOtherInterpreter(outcome)
execute(next(outcome))
}
}
conner
11/28/2023, 2:10 PMCoproduct
, where each interpreter doesn't have to be aware of the others?Alejandro Serrano.Mena
11/28/2023, 2:31 PMcontext(Casino, OtherTagless) fun doSomething(): A
and then interpret as you wishconner
11/28/2023, 3:40 PM