clearEvents :: Env -> Dbi -> RIO e ()
clearEvents env eventsTbl =
    rwith (writeTxn env) $ \txn ->
    rwith (cursor txn eventsTbl) $ \cur ->
    withKVPtrs' nullVal nullVal $ \pKey pVal -> do
        let loop = io (mdb_cursor_get MDB_LAST cur pKey pVal) >>= \case
                False -> pure ()
                True  -> do io $ mdb_cursor_del (compileWriteFlags []) cur
                            loop
        loop
clearEvents :: Env -> Dbi -> RIO e ()
clearEvents env eventsTbl =
    rwith (writeTxn env) $ \txn ->
    rwith (cursor txn eventsTbl) $ \cur ->
    withKVPtrs' nullVal nullVal $ \pKey pVal -> do
        let loop = io (mdb_cursor_get MDB_LAST cur pKey pVal) >>= \case
                False -> pure ()
                True  -> do io $ mdb_cursor_del (compileWriteFlags []) cur
                            loop
        loop
clearEvents env eventsTbl =
    rwith (writeTxn env) $ \txn ->
    rwith (cursor txn eventsTbl) $ \cur ->
    withKVPtrs' nullVal nullVal $ \pKey pVal -> do
        let loop = io (mdb_cursor_get MDB_LAST cur pKey pVal) >>= \case
                False -> pure ()
                True  -> do io $ mdb_cursor_del (compileWriteFlags []) cur
                            loop
        loop