11package com .thoughtworks .dsl
22package keywords
33import Dsl .IsKeyword
4+ import Dsl .!!
45import Dsl .cpsApply
56import scala .concurrent .Future
67import scala .concurrent .ExecutionContext
@@ -17,19 +18,26 @@ object Suspend extends Suspend.LowPriority0 {
1718 upstreamIsKeyword : => IsKeyword [Upstream , UpstreamValue ]
1819 ): IsKeyword [Suspend [Upstream ], UpstreamValue ] with {}
1920
20- private [Suspend ] trait LowPriority0 :
21+ private [Suspend ] trait LowPriority1 :
2122 given [Keyword , Domain , Value ](using
2223 Dsl .Searching [Keyword , Domain , Value ]
2324 ): Dsl .Composed [Suspend [Keyword ], Domain , Value ] = Dsl .Composed {
2425 (keyword : Suspend [Keyword ], handler : Value => Domain ) =>
2526 keyword().cpsApply(handler)
2627 }
28+ private [Suspend ] trait LowPriority0 extends LowPriority1 :
29+ given [Keyword , State , Domain , Value ](using
30+ Dsl .Searching [Keyword , State => Domain , Value ]
31+ ): Dsl .Composed [Suspend [Keyword ], State => Domain , Value ] = Dsl .Composed {
32+ (keyword : Suspend [Keyword ], handler : Value => State => Domain ) =>
33+ Dsl .TrampolineFunction1 (() => keyword().cpsApply(handler))
34+ }
2735
28- given [Keyword , State , Domain , Value ](using
29- Dsl .Searching [Keyword , State => Domain , Value ]
30- ): Dsl .Composed [Suspend [Keyword ], State => Domain , Value ] = Dsl .Composed {
31- (keyword : Suspend [Keyword ], handler : Value => State => Domain ) => value =>
32- keyword().cpsApply(handler)(value )
36+ given [Keyword , Domain , Value ](using
37+ Dsl .Searching [Keyword , Domain !! Throwable , Value ]
38+ ): Dsl .Composed [Suspend [Keyword ], Domain !! Throwable , Value ] = Dsl .Composed {
39+ (keyword : Suspend [Keyword ], handler : Value => ( Domain !! Throwable )) =>
40+ Dsl . TrampolineContinuation (() => keyword().cpsApply(handler))
3341 }
3442
3543 given [Keyword , Result , Value ](using
0 commit comments