Currently, there's nothing at compile time preventing users from not calling handle tactics. I think we can add more restriction by forcing users to return special values which only produced by handle tactics. But I'm also concerning that this would make writing handlers little more complicated. Any thoughts?
type TacticIsCalled = unique symbol // some special type
interface HandleTactics<in ER, in R> {
resume(value: ER): TacticIsCalled
abort(value: R): TacticIsCalled
}
type Handlers<E extends Effects, R = never>
= Simplify<
UnionToIntersection<
E extends Code<`${infer S}.${infer C}`, infer P, infer ER> ?
Eq<P, never> extends false ?
{ [K in S]: { [K in C]: (...parameters: [...P, HandleTactics<ER, R>]) => TacticIsCalled | Generator<Effects, TacticIsCalled > } }
: { [K in S]: { [K in C]: ER | Generator<Effects, ER> } }
: never
>
>
Currently, there's nothing at compile time preventing users from not calling handle tactics. I think we can add more restriction by forcing users to return special values which only produced by handle tactics. But I'm also concerning that this would make writing handlers little more complicated. Any thoughts?