Pick.search.cheap: def of bolt@1.27.0.0 Import: import bolt@1.27.0.0/src/rules/correctness/pick.bend as Pick Lines 169-191 of bolt@1.27.0.0/src/rules/correctness/pick.bend: https://jend.leeeet.dev/read.txt?path=bolt@1.27.0.0/src/rules/correctness/pick.bend&start_line=169&end_line=191 import Base import bolt@1.27.0.0/src/syntax/lex.bend as Lex import bolt@1.27.0.0/src/syntax/tree.bend as Tree import bolt@1.27.0.0/src/rules/calls.bend as Calls # does a `Bool.pick(..)` under the node, at any depth, have the condition # whose text is cond? def search.cheap(nn: Tree.Node, +cond: String) -> Bool: match nn: case Tree.NCons{Tree.Leaf{Lex.Tok{_k, +t, _l, _c}}, Tree.NCons{Tree.Group{Lex.Tok{_ko, +o, _lo, _co}, +kids, _cl}, rest}}: +here = Bool.and(Bool.and(String.eq(t, "Bool.pick"), String.eq(o, "(")), String.eq(search.text(Calls.arg(Calls.args(kids), 1n)), cond)) +a = search.cheap(kids, cond) +b = search.cheap(rest, cond) Bool.or(here, Bool.or(a, b)) case Tree.Group{_o, kids, _cl}: search.cheap(kids, cond) case Tree.Stmt{_k, kids, body}: +a = search.cheap(kids, cond) +b = search.cheap(body, cond) Bool.or(a, b) case Tree.NCons{h, t}: +a = search.cheap(h, cond) +b = search.cheap(t, cond) Bool.or(a, b) case _other: False{} Uses (10): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.or https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=String.eq https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/calls.bend&name=arg https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/calls.bend&name=args https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/rules/correctness/pick.bend&name=search.text https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/lex.bend&name=Tok https://jend.leeeet.dev/definition.txt?path=bolt@1.27.0.0/src/syntax/tree.bend&name=Node