context billing.charge

capability Clock {
  fn now() -> Effect[Int]
}

provides Clock = FixedClock {
  fn now() -> Effect[Int] {
    42
  }
}

fn bad(n: Int) -> Int {
  let s = n + true
  s
}

fn good(n: Int) -> Int {
  let m = n * 2
  m
}

service charge {
  on call(cents: Int) -> Effect[Result[Int, ()]] given Clock {
    let stamp <- Clock.now()
    Ok(cents + stamp)
  }
}
