def attach

yaml-for-bend@0.1.1.0 · compose.bend:333

import yaml-for-bend@0.1.1.0/compose.bend as Compose
import Base

333# A finished node goes to the collection it's in, or is the document.
334def attach(co: Co, item: Item) -> Co:
335  match co:
336    case Co{stack, anchors, count, root, docs, opened, depth, copied}:
337      match stack:
338        case Nil{}:
339          Co{[], anchors, count, Some{item.val(item)}, docs, opened, depth, copied}
340        case Con{top, rest}:
341          match top:
342            case OSeq{anchor, tag, items, start, at}:
343              Co{OSeq{anchor, tag, item.val(item) <> items, start, at} <> rest, anchors, count, root, docs, opened, depth, copied}
344            case OMap{anchor, tag, items, start, at}:
345              Co{OMap{anchor, tag, item <> items, start, at} <> rest, anchors, count, root, docs, opened, depth, copied}

Uses (6)

Used by (1)