def laws_of
bolt@1.27.0.0 · src/rules/digest.bend:290
import bolt@1.27.0.0/src/rules/digest.bend as Digest
import Base
import bolt@1.27.0.0/src/syntax/tree.bend as Tree
import bolt@1.27.0.0/src/syntax/bind.bend as Bind
import bolt@1.27.0.0/src/syntax/outline.bend as Outline
import bolt@1.27.0.0/src/rules/laws/closed.bend as Closed
290
291
292
293def laws_of(root: Tree.Node, +items: List<&2, Outline.Item>) -> List<&2, Law>:
294 match root:
295 case Tree.NCons{Tree.Stmt{Tree.SLaw{}, +kids, body}, rest}:
296 +at = Tree.line(kids)
297 +left = from_line(items, at, from_line.stop(items, at))
298 dd = doc_at(left, at)
299 Law{Closed.name.of(Bind.declared(kids)), at, Closed.binds(body), String.lines(dd)} <> laws_of(rest, left)
300 case Tree.NCons{h, rest}:
301 laws_of(rest, items)
302 case other:
303 Nil{}