-- Failver and replace the secondary (f, r:ns)
applyMove nl inst (FailoverAndReplace new_sdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_sdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_p = Node.offline old_p
      new_nl = do -- Maybe monad
        new_p <- Node.addPriEx force_p int_s inst
        new_s <- Node.addSecEx force_p tgt_n inst old_sdx
        let new_inst = Instance.setBoth inst old_sdx new_sdx
        return (Container.add new_sdx new_s $
                Container.addTwo old_sdx new_p old_pdx int_p nl,
                new_inst, old_sdx, new_sdx)
  in new_nl
applyMove nl inst (FailoverAndReplace new_sdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_sdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_p = Node.offline old_p
      new_nl = do -- Maybe monad
        new_p <- Node.addPriEx force_p int_s inst
        new_s <- Node.addSecEx force_p tgt_n inst old_sdx
        let new_inst = Instance.setBoth inst old_sdx new_sdx
        return (Container.add new_sdx new_s $
                Container.addTwo old_sdx new_p old_pdx int_p nl,
                new_inst, old_sdx, new_sdx)
  in new_nl
applyMove nl inst (FailoverAndReplace new_sdx) =
  let (old_pdx, old_sdx, old_p, old_s) = instanceNodes nl inst
      tgt_n = Container.find new_sdx nl
      int_p = Node.removePri old_p inst
      int_s = Node.removeSec old_s inst
      force_p = Node.offline old_p
      new_nl = do -- Maybe monad
        new_p <- Node.addPriEx force_p int_s inst
        new_s <- Node.addSecEx force_p tgt_n inst old_sdx
        let new_inst = Instance.setBoth inst old_sdx new_sdx
        return (Container.add new_sdx new_s $
                Container.addTwo old_sdx new_p old_pdx int_p nl,
                new_inst, old_sdx, new_sdx)
  in new_nl