def foreign.opens
import bolt@1.27.0.0/src/rules/suspicious/unused.bend as Unusedimport Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
60# does the body open with an import once the def's header is over? While the
61# header is open (its tokens so far do not end in `:`), each statement is more
62# of it: `-> IO(T):` on the line after `def f(..) ->`
63def foreign.opens(body: Tree.Node, open: Bool) -> Bool:
64 match body:
65 case Tree.NCons{Tree.Stmt{sk, kids, _b}, rest}:
66 match open:
67 case True{}:
68 foreign.opens(rest, Bool.not(foreign.ends(kids, False{})))
69 case False{}:
70 foreign.first(sk)
71 case other:
72 False{}