def float.of

yaml-for-bend@0.1.1.0 · yaml11.bend:173

import yaml-for-bend@0.1.1.0/yaml11.bend as Yaml11
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
import yaml-for-bend@0.1.1.0/core.bend as C

173def float.of(+s: String) -> Maybe<&2, String>:
174  +body = C.unsigned(s)
175  when(Maybe<&2, String>, C.is_inf(body), u => Some{Bool.pick(String, C.is_neg(s), "-.inf", ".inf")},
176    u => when(Maybe<&2, String>, C.is_nan(s), u => Some{".nan"},
177      u => when(Maybe<&2, String>, Bool.and(R.matches(float.pat(), s), has_digit(s)), u => Some{N.dec.exact(no.seps(s))},
178        u => when(Maybe<&2, String>, R.matches(sexa.float.pat(), s), u => Some{sexa.float(s)}, u => None{}))))

Uses (16)

Used by (2)