-- Replace the secondary and failover (r:np, f)
applyMove nl inst (ReplaceAndFailover new_pdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_pdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_s = Node.offline old_s
      new_nl = do -- Maybe monad
        new_p <- Node.addPri tgt_n inst
        new_s <- Node.addSecEx force_s int_p inst new_pdx
        let new_inst = Instance.setBoth inst new_pdx old_pdx
        return (Container.add new_pdx new_p $
                Container.addTwo old_pdx new_s old_sdx int_s nl,
                new_inst, new_pdx, old_pdx)
  in new_nl
applyMove nl inst (ReplaceAndFailover new_pdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_pdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_s = Node.offline old_s
      new_nl = do -- Maybe monad
        new_p <- Node.addPri tgt_n inst
        new_s <- Node.addSecEx force_s int_p inst new_pdx
        let new_inst = Instance.setBoth inst new_pdx old_pdx
        return (Container.add new_pdx new_p $
                Container.addTwo old_pdx new_s old_sdx int_s nl,
                new_inst, new_pdx, old_pdx)
  in new_nl
applyMove nl inst (ReplaceAndFailover new_pdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_pdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_s = Node.offline old_s
      new_nl = do -- Maybe monad
        new_p <- Node.addPri tgt_n inst
        new_s <- Node.addSecEx force_s int_p inst new_pdx
        let new_inst = Instance.setBoth inst new_pdx old_pdx
        return (Container.add new_pdx new_p $
                Container.addTwo old_pdx new_s old_sdx int_s nl,
                new_inst, new_pdx, old_pdx)
  in new_nl