fn sum<S, T>(state: S, input: T, retract: bool) -> Result<S>where S: Default + From<T> + CheckedAdd<Output = S> + CheckedSub<Output = S>,