def ws.go
import bend-net-json@0.3.0.0/json.bend as Jsonimport Base
42# Bool.pick runs both arms, so loops peek: the next char's class is a Bool
43# param and only the matching arm recurses.
44def ws.go(t: String, +c: U32, ws: Bool) -> String:
45 match t:
46 case SNil{}:
47 match ws:
48 case True{}:
49 SNil{}
50 case False{}:
51 SCon{Chr{c}, SNil{}}
52 case SCon{Chr{+d}, u}:
53 match ws:
54 case True{}:
55 ws.go(u, d, is_ws(d))
56 case False{}:
57 SCon{Chr{c}, SCon{Chr{d}, u}}