emitNode
  :: (Monad p1, Monad p2, Monad p3)
  => EmitST2Array Position Int r w p1 p2 p3 tc
  -> Delay p2 p3 tc
  -> p3 (Array Node Position)
  -> [Node]
  -> MultiPass r w tc (p2 Position)
emitNode emitter delay12 offsets ys =
  do -- Emit the number of edges.
     emit emitter (return (length ys))
     sequence_
       [ do -- Emit a relative offset for each edge.
            pos <- getIndex emitter
            emit emitter $
              do pos' <- delay delay12 pos
                 offsets' <- offsets
                 let offset = offsets' ! y
                 return (positionDiff offset pos')
       | y <- ys
       ]
     getIndex emitter
emitNode
  :: (Monad p1, Monad p2, Monad p3)
  => EmitST2Array Position Int r w p1 p2 p3 tc
  -> Delay p2 p3 tc
  -> p3 (Array Node Position)
  -> [Node]
  -> MultiPass r w tc (p2 Position)
emitNode emitter delay12 offsets ys =
  do -- Emit the number of edges.
     emit emitter (return (length ys))
     sequence_
       [ do -- Emit a relative offset for each edge.
            pos <- getIndex emitter
            emit emitter $
              do pos' <- delay delay12 pos
                 offsets' <- offsets
                 let offset = offsets' ! y
                 return (positionDiff offset pos')
       | y <- ys
       ]
     getIndex emitter
emitNode emitter delay12 offsets ys =
  do -- Emit the number of edges.
     emit emitter (return (length ys))
     sequence_
       [ do -- Emit a relative offset for each edge.
            pos <- getIndex emitter
            emit emitter $
              do pos' <- delay delay12 pos
                 offsets' <- offsets
                 let offset = offsets' ! y
                 return (positionDiff offset pos')
       | y <- ys
       ]
     getIndex emitter