CHECKED NARROWING (L11n, NUM-005): `StdSome` exactly when the value is
representable at the narrower width, `StdNone` otherwise (the wrapping
narrows above keep the low bytes regardless). Unsigned: every dropped byte
must be zero. Signed: every dropped byte must equal the sign byte of the
kept part, so the value sign-extends back to itself.
666def stdU16ToU8Checked =
667 (lambda unrestricted value : (family StdU16) .
668 (eliminate
669 StdU16
670 (lambda unrestricted current : (family StdU16) . (family StdOption Byte))
671 value
672 (branch
673 StdU16Of
674 low
675 high
676 .
677 (nat-eliminate
678 (lambda unrestricted current : Nat . (family StdOption Byte))
679 (constructor StdOption StdNone Byte)
680 (lambda unrestricted predecessor : Nat .
681 (lambda unrestricted induction : (family StdOption Byte) .
682 (constructor StdOption StdSome Byte low)))
683 (byte-equal high (byte 0))))))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.