Ask

com.softinio.verdict4s.Ask
See theAsk companion object
final class Ask[Q <: Tuple]

A set of questions asked together, answered at exactly the right types.

One request carrying several questions is both cheaper and faster than one request each, and it is the shape the service is designed around. Ask keeps that batching while preserving each question's own answer type:

val (urgent, dept, mood) = client.ask(
 Ask(
   Question.noul("Does this convey urgency?"),
   Question.choice[Dept]("Which team should handle this?"),
   Question.score("How frustrated?", Seq("Calm", "Cross", "Livid"))
 ),
 state
)

urgent is a NoulAnswer, dept a ChoiceAnswer[Dept] and mood a ScoreAnswer -- destructured positionally, with no casts and no lookups by string. The map-based algebra.Evaluation remains available for cases where the questions are not known statically.

Question keys are generated positionally, so callers never name them. Use withKeys if you need them to match something else.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

Project a response back into the positional answer tuple.

Project a response back into the positional answer tuple.

This is the only place in the library that casts. Both are justified by the same fact: the list is built by walking the very tuple that Ask.Answers is computed from, in the same order, so element i has the type the match type assigns to position i.

Attributes

The model override, if one was set.

The model override, if one was set.

Attributes

def request[S : Encoder](state: S, defaultModel: Model): ValidatedNec[Validation, EvaluationRequest]

Build the request, or report every problem with it at once.

Build the request, or report every problem with it at once.

Attributes

Every question validated once, with failures accumulated across the whole tuple rather than stopping at the first bad one.

Every question validated once, with failures accumulated across the whole tuple rather than stopping at the first bad one.

Attributes

def withKeys(f: Int => String): Ask[Q]

Choose the question keys yourself, by position.

Choose the question keys yourself, by position.

Attributes

def withModel(m: Model): Ask[Q]

Ask these questions of a specific model rather than the client default.

Ask these questions of a specific model rather than the client default.

Attributes