def float.of
import yaml-for-bend@0.1.1.0/core.bend as Coreimport Base
import yaml-for-bend@0.1.1.0/re.bend as R
84# A float's text, if +s+ is one: as written, or ".inf", "-.inf", ".nan".
85def float.of(+s: String) -> Maybe<&2, String>:
86 +u = unsigned(s)
87 Bool.pick(Maybe<&2, String>, is_inf(u), Some{Bool.pick(String, is_neg(s), "-.inf", ".inf")},
88 Bool.pick(Maybe<&2, String>, is_nan(s), Some{".nan"},
89 Bool.pick(Maybe<&2, String>, R.matches(float.pat(), s), Some{s}, None{})))