writeTRef :: (MonadRef m, Eq a) =>  TRef m a -> a -> TransM a m ()
writeTRef cell v = do
  cur <- readRef (current cell)
  unless (v == cur) $ do
    com <- readRef (committed cell)
    when (cur == com) $ do
      stack <- ask
      transactions <- readRef stack
      writeRef stack (cell : transactions)
    writeRef (current cell) v
writeTRef :: (MonadRef m, Eq a) =>  TRef m a -> a -> TransM a m ()
writeTRef cell v = do
  cur <- readRef (current cell)
  unless (v == cur) $ do
    com <- readRef (committed cell)
    when (cur == com) $ do
      stack <- ask
      transactions <- readRef stack
      writeRef stack (cell : transactions)
    writeRef (current cell) v
writeTRef cell v = do
  cur <- readRef (current cell)
  unless (v == cur) $ do
    com <- readRef (committed cell)
    when (cur == com) $ do
      stack <- ask
      transactions <- readRef stack
      writeRef stack (cell : transactions)
    writeRef (current cell) v