def count_err
import bend-schema-lib@0.4.1.0/core.bend as Coreimport Base
836# The count, as an error: at an SListLen the count is read before any element,
837# so a list out of bounds is CountNotIn at the list's own path. A value that is
838# not a list has no count to object to, and is refused as a list schema refuses
839# it: NotList, or Missing/TooLarge for the two nodes that are never a shape
840# (the same reasons check's own arms give them).
841def count_err(+lo: Nat, +hi: Nat, r: Raw) -> Maybe<&2, Err>:
842 match r:
843 case RNil{}:
844 in_err(list_len_ok(lo, hi, r), CountNotIn{lo, hi})
845 case RCons{h, t}:
846 in_err(list_len_ok(lo, hi, r), CountNotIn{lo, hi})
847 case _:
848 here(missing_or(r, NotList{}))