def int.of
yaml-for-bend@0.1.1.0 · core.bend:73
import yaml-for-bend@0.1.1.0/core.bend as Core
import Base
import yaml-for-bend@0.1.1.0/re.bend as R
import yaml-for-bend@0.1.1.0/num.bend as N
73
74def int.of(+s: String) -> Maybe<&2, String>:
75 when(Maybe<&2, String>, R.matches(dec.pat(), s), u => Some{N.int.text(is_neg(s), unsigned(s), 10n)},
76 u => when(Maybe<&2, String>, R.matches(oct.pat(), s), u => Some{N.int.text(False{}, String.drop(s, 2n), 8n)},
77 u => when(Maybe<&2, String>, R.matches(hex.pat(), s), u => Some{N.int.text(False{}, String.drop(s, 2n), 16n)}, u => None{})))