def is_binder

bend-lint-rules@0.2.0.0 · performance/unused_result.bend:62

import bend-lint-rules@0.2.0.0/performance/unused_result.bend as UnusedResult
import Base
import bend-lint-api@0.2.0.0/linter/lint.bend as Lint

62# Whether a node of this kind, below `path`, binds a value at run time: a lambda's parameter (not a `do` step's), or a
63# let's name (a binding, or the one pattern variable of a let), not erased.
64def is_binder(syntax: Lint.Syntax, path: List<&2, Lint.Above>) -> Bool:
65  match syntax path:
66    case Lint.Lambda{b, Some{Lint.Erased{}}} _:
67      False{}
68    case Lint.Lambda{b, q} _:
69      Bool.not(is_step(path))
70    case Lint.Binding{b, Lint.Erased{}} _:
71      False{}
72    case Lint.Binding{b, q} _:
73      True{}
74    case Lint.PatternVariable{b, Lint.Erased{}} _:
75      False{}
76    case Lint.PatternVariable{
77      b,
78      q
79    } Con{Lint.Above{Lint.Node{Lint.Destructure{d}, n, s, k, f}, at}, rest}:
80      True{}
81    case _ _:
82      False{}

Uses (9)

Used by (1)