Tin

Examples · learn/17-typed-replies · 227 of 339

task-2.solution

examples/learn/17-typed-replies/task-2.solution.tintin run examples/learn/17-typed-replies/task-2.solution.tin
type Mood = | Happy | Neutral | Upset

agent Reader { model: "mock" }

fn reply(m: Mood): string => match m {
  Happy => "Glad to hear it!"
  Neutral => "Thanks for the note."
  Upset => "Sorry about that. A person will call you."
}

fn main() {
  let mood: Mood = Reader("how does this customer feel? 'Upset'")
  print(reply(mood))
}