def Syntax.declares

bend-lint-api@0.2.0.0 · linter/lint.bend:187

import bend-lint-api@0.2.0.0/linter/lint.bend as Lint
import Base

187# Whether a node of this kind declares a global name (Some{True{}}), a binder of its top-level declaration
188# (Some{False{}}), or nothing (an import declares an alias, which Declarations below handles).
189def Syntax.declares(syntax: Syntax) -> Maybe<&2, Bool>:
190  match syntax:
191    case Definition{t, u}:
192      Some{True{}}
193    case Datatype{t}:
194      Some{True{}}
195    case Constructor{t}:
196      Some{True{}}
197    case Law{t}:
198      Some{True{}}
199    case Parameter{b, q}:
200      Some{False{}}
201    case Field{b, q}:
202      Some{False{}}
203    case Binding{b, q}:
204      Some{False{}}
205    case Lambda{b, q}:
206      Some{False{}}
207    case Forall{b, q}:
208      Some{False{}}
209    case PatternVariable{b, q}:
210      Some{False{}}
211    case _:
212      None{}

Uses (3)

Used by (2)