def co.alias
yaml-for-bend@0.1.1.0 · compose.bend:493
import yaml-for-bend@0.1.1.0/compose.bend as Compose
import Base
import yaml-for-bend@0.1.1.0/token.bend as T
import yaml-for-bend@0.1.1.0/value.bend as V
493
494
495def co.alias(co: Co, +name: String, +limit: Nat, +at: T.Mark) -> Result<&2, &2, T.Error, Co>:
496 match co:
497 case Co{+stack, +anchors, count, root, docs, opened, depth, copied}:
498 when(Result<&2, &2, T.Error, Co>, opens(stack, name),
499 u => Fail{content("found an alias to a node that holds it: " ++ name ++ " is recursive, and a tree can't hold a cycle", at)},
500 u => when(Result<&2, &2, T.Error, Co>, Bool.not(found(Map.has(&2, Anchored, anchors, name))),
501 u => Fail{content("found an alias to an unknown anchor: " ++ name, at)},
502 u => alias.got(Map.get(Anchored, Anchored{V.Null{}, 0n}, anchors, name), Co{stack, anchors, count, root, docs, opened, depth, copied}, limit, at)))