1 import Base 2 3 # Returns the count-limit decision for a mutation batch. 4 type Validation is Data: 5 ValidBatch{} 6 EmptyBatch{} 7 BatchCountExceeded{} 8 9 # Returns the maximum number of mutations in a batch. 10 def max_batch_count() -> Nat: 11 256n 12 13 # Checks whether a batch count is within the allowed range. 14 def within_batch_count(count: Nat) -> Bool: 15 Nat.is_le(count, max_batch_count()) 16 17 # Rejects empty and oversized batches before writing. 18 def validate_count(count: Nat) -> Validation: 19 match count: 20 case 0n: 21 EmptyBatch{} 22 case count: 23 Bool.pick(Validation, within_batch_count(count), ValidBatch{}, BatchCountExceeded{})