Check before addition. Runtime Nat is machine-sized, so a post-add check could
observe a wrapped value and is not acceptable.
238def dataBytesCheckedAddWithin =
239 (lambda unrestricted limit : Nat .
240 unrestricted failure : (family DataBytesErrorCode) .
241 unrestricted left : Nat .
242 unrestricted right : Nat .
243 nat-eliminate
244 (lambda unrestricted current : Nat . family DataBytesCheckedNaturalResult)
245 (constructor DataBytesCheckedNaturalResult DataBytesCheckedNaturalFailed failure)
246 (lambda unrestricted leftFitsPredecessor : Nat .
247 unrestricted leftFitsInduction : (family DataBytesCheckedNaturalResult) .
248 nat-eliminate
249 (lambda unrestricted current : Nat . family DataBytesCheckedNaturalResult)
250 (constructor DataBytesCheckedNaturalResult DataBytesCheckedNaturalFailed failure)
251 (lambda unrestricted rightFitsPredecessor : Nat .
252 unrestricted rightFitsInduction : (family DataBytesCheckedNaturalResult) .
253 constructor
254 DataBytesCheckedNaturalResult
255 DataBytesCheckedNaturalSucceeded
256 (naturalAdd left right))
257 (naturalLessOrEqual right (naturalSaturatingSubtract limit left)))
258 (naturalLessOrEqual left limit))The compiler supplied declaration spans and resolved links from this source snapshot. This page does not assert that this file belongs to a checked closure.