final class Scenario[F[_], +A] extends AnyVal
Description of an interaction between two parties, where generally one is the application (bot) and the other is Telegram user.
Particular interaction is coherent with some scenario as long as it matches the description (i.e. every step of the interaction matches the step described in scenario).
Scenario forms a monad in A with pure and flatMap.
- Alphabetic
- By Inheritance
- Scenario
- AnyVal
- Any
- Hide All
- Show All
- Public
- All
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##(): Int
- Definition Classes
- Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def >>[B](s2: => Scenario[F, B]): Scenario[F, B]
Lazy
flatMapwhich ignores the result of the first scenario. - final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def attempt: Scenario[F, Either[Throwable, A]]
- returns
Scenario which wraps successful result values in
Rightand raised errors inLeft.
- def flatMap[B](fn: (A) => Scenario[F, B]): Scenario[F, B]
Chains this scenario with the one produced by applying
fnto the result of this scenario. - def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def handleErrorWith[A2 >: A](fn: (Throwable) => Scenario[F, A2]): Scenario[F, A2]
- returns
thisor scenario which is result of provided function if error occurs.
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def map[B](fn: (A) => B): Scenario[F, B]
Maps successful result values using provided function.
- def mapK[G[_]](f: ~>[F, G]): Scenario[G, A]
Maps effect type from
FtoGusing the supplied transformation.Maps effect type from
FtoGusing the supplied transformation.Warning: this operation can result into StackOverflowError if
thisis nested with a lot offlatMapoperations. - def pipe(implicit F: ApplicativeError[F, Throwable]): Pipe[F, TelegramMessage, A]
Pipe which produces a stream with at most single value of type
Aevaluated inFeffect as a result of the successful interaction matching this description.Pipe which produces a stream with at most single value of type
Aevaluated inFeffect as a result of the successful interaction matching this description. If an unhandled error result was encountered during the interaction, it will be raised here. - def stopOn(p: (TelegramMessage) => Boolean): Scenario[F, A]
Stops this scenario on first input message matching the predicate.
- def stopWith(p: (TelegramMessage) => Boolean)(cancellation: (TelegramMessage) => F[Unit]): Scenario[F, A]
Stops this scenario on first input message matching the predicate and evaluates cancellation function with this message.
- def toString(): String
- Definition Classes
- Any
- def tolerate(fn: (TelegramMessage) => F[Unit]): Scenario[F, A]
Alias for tolerateN(1)
- def tolerateAll(fn: (TelegramMessage) => F[Unit]): Scenario[F, A]
Same as tolerateN, but retries until the scenario is fully matched.
Same as tolerateN, but retries until the scenario is fully matched.
Often used in combination with stopOn/stopWith to give users a way to 'escape' the scenario.
- def tolerateN(n: Int)(fn: (TelegramMessage) => F[Unit]): Scenario[F, A]
Restarts this scenario if it was mismatched, up to
ntimes, evaluatingfnapplied to the input element that was mismatched.Restarts this scenario if it was mismatched, up to
ntimes, evaluatingfnapplied to the input element that was mismatched.This can be useful, when you expect some input from the user (e.g. data in specific format) and want to retry if the input was not correct.