1 import Base 2 3 # Negative{n} denotes -(n+1), so zero has exactly one representation. 4 type Integer is Data: 5 Positive{magnitude: Nat} 6 Negative{predecessor: Nat} 7 8 type Int64 is Data: 9 I64{bits: Word(64n)} 10 11 type Metrics is Data: 12 Counts{inserts: Word(64n), evictions: Word(64n), removals: Word(64n), hits: Word(64n), misses: Word(64n)} 13 14 type Entry<-K: Data, -V: Data> is Data: 15 Item{key: K, value: V, deadline: Int64} 16 17 type LruEvent<-K: Data, -V: Data> is Data: 18 Evicted{key: K, value: V} 19 20 def zero_metrics() -> Metrics: 21 Counts{Word.zero(64n), Word.zero(64n), Word.zero(64n), Word.zero(64n), Word.zero(64n)}