def int.of
import bend-kit-redis@0.3.0.0/redis.bend as Redisimport Base
293# RESP integers are signed 64-bit: the magnitude may reach 2^63 only when negative.
294def int.of(n: Num) -> Maybe<&1, Val>:
295 Num{+neg, +hi, +lo, ok} = n
296 +fits = Bool.or(U32.is_lt(hi, 2147483648), Bool.and(neg, Bool.and(U32.is_eq(hi, 2147483648), U32.is_eq(lo, 0))))
297 int.val(Bool.and(ok, fits), neg, hi, lo)