def lams
bolt@1.27.0.0 · src/rules/suspicious/thunk.bend:130
import bolt@1.27.0.0/src/rules/suspicious/thunk.bend as Thunk
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
130
131
132def lams(nn: Tree.Node, +seen: Bool) -> Nat:
133 match nn:
134 case Tree.NCons{Tree.Leaf{Lex.Tok{k, t, _l, _c}}, rest}:
135 +comma = Lex.is_comma(k)
136 Nat.add(Bool.pick(Nat, Bool.and(comma, seen), 1n, 0n),
137 lams(rest, Bool.and(Bool.not(comma), Bool.or(seen, String.eq(t, "=>")))))
138 case Tree.NCons{_h, rest}:
139 lams(rest, seen)
140 case _other:
141 Bool.pick(Nat, seen, 1n, 0n)