 M: byte-array apply-merge-keys nip ;
 M: string apply-merge-keys nip ;
 M: assoc apply-merge-keys
-    [ [ ?apply-merge-keys ] bi-curry@ bi ] with2 assoc-map!
+    [ [ ?apply-merge-keys ] bi-curry@ bi ] withd assoc-map!
     merge get [ ?apply-merge-key ] when
     value get [ ?apply-default-key ] when ;
 

        [ 2drop ] [ 1array yaml-unexpected-event ] if
    ] with-destructors ;

! Same as 'with', but for combinators that
! put 2 arguments on the stack
: with2 ( param obj quot -- obj curry )
    swapd '[ [ _ ] 2dip @ ] ; inline

GENERIC: (deref-aliases) ( anchors obj -- obj' )

M: object (deref-aliases) nip ;

    [
        [ emit-mapping-key ]
        [ emit-object ] bi-curry* 2bi
    ] withd withd assoc-each ;

: emit-linked-assoc-body ( emitter event linked-assoc -- )
    >alist [ first2 swap associate ] map emit-sequence-body ;
