def wf

bend-schema-lib@0.4.1.0 · core.bend:1833

import bend-schema-lib@0.4.1.0/core.bend as Core
import Base

1833def wf(s: Schema) -> Bool:
1834  match s:
1835    case SOpt{+i}:
1836      Bool.and(Bool.not(nullable(i)), wf(i))
1837    case SOptional{+i}:
1838      Bool.and(Bool.not(opt_at(i)), wf(i))
1839    case SList{+e}:
1840      Bool.and(Bool.not(opt_at(e)), wf(e))
1841    case SListLen{lo_, hi_, +s2}:
1842      Bool.and(Bool.not(opt_at(s2)), wf(s2))
1843    case SStrLen{lo_, hi_, +s2}:
1844      Bool.and(Bool.not(opt_at(s2)), wf(s2))
1845    case SField{+n, fs, +rest}:
1846      Bool.and(wf(fs), Bool.and(fresh_f(n, rest), wf(rest)))
1847    case SRule{+s2, tag}:
1848      Bool.and(Bool.not(opt_at(s2)), wf(s2))
1849    case SStrict{+s2}:
1850      Bool.and(is_keyed(s2), Bool.and(Bool.not(opt_at(s2)), wf(s2)))
1851    case STagged{+k, +n, +cs, +rest}:
1852      Bool.and(Bool.not(opt_at(cs)), Bool.and(wf(cs), Bool.and(no_key(k, cs), Bool.and(fresh_t(k, n, rest), wf(rest)))))
1853    case SVariant{+n, +vs, +rest}:
1854      Bool.and(Bool.not(opt_at(vs)), Bool.and(wf(vs), Bool.and(fresh_v(n, rest), wf(rest))))
1855    case STuple{+ts, +rest}:
1856      Bool.and(Bool.not(opt_at(ts)), Bool.and(wf(ts), Bool.and(Bool.not(opt_at(rest)), wf(rest))))
1857    case SJson{}:
1858      True{}
1859    case SEither{+l, +r}:
1860      Bool.and(alt_ok(l), Bool.and(alt_ok(r), Bool.and(disjoint(l, r), Bool.and(wf(l), wf(r)))))
1861    case _:
1862      True{}

Uses (13)

Used by (0)

No other definition uses this definition.