context demo.counter

exports transparent { CounterError }

type CounterError = enum { Overflow }

agent Counter {
  key id: String

  store count: Cell[Int]

  on call increment() -> Effect[Result[Int, CounterError]] {
    let next = count + 1
    count := next
    Ok(next)
  }
}

service bump {
  on call(id: String) -> Effect[Result[Int, CounterError]] {
    let c = Counter(id)
    let t <- c.increment()
    t
  }
}
