incrDecr :: (Word64 -> IO a) -> Failure a -> OpCode -> CAS
         -> Key -> Delta -> Initial -> Expiry -> Handle -> IO a
incrDecr success failure op cas key delta initial expiry =
    withRequest op key 20 extra 0 nop cas success' failure
  where
    extra p = do
        pokeWord64be          p     delta
        pokeWord64be (plusPtr p  8) initial
        pokeWord32be (plusPtr p 16) expiry

    success' h p = do
        len <- hGetBuf h p 8
        if len /= 8
            then failure DataReadFailed
            else peekWord64be p >>= success
incrDecr :: (Word64 -> IO a) -> Failure a -> OpCode -> CAS
         -> Key -> Delta -> Initial -> Expiry -> Handle -> IO a
incrDecr success failure op cas key delta initial expiry =
    withRequest op key 20 extra 0 nop cas success' failure
  where
    extra p = do
        pokeWord64be          p     delta
        pokeWord64be (plusPtr p  8) initial
        pokeWord32be (plusPtr p 16) expiry

    success' h p = do
        len <- hGetBuf h p 8
        if len /= 8
            then failure DataReadFailed
            else peekWord64be p >>= success
incrDecr success failure op cas key delta initial expiry =
    withRequest op key 20 extra 0 nop cas success' failure
  where
    extra p = do
        pokeWord64be          p     delta
        pokeWord64be (plusPtr p  8) initial
        pokeWord32be (plusPtr p 16) expiry

    success' h p = do
        len <- hGetBuf h p 8
        if len /= 8
            then failure DataReadFailed
            else peekWord64be p >>= success