summaryrefslogtreecommitdiff
path: root/main/Main.hs
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2026-08-02 22:22:15 +0200
committerRoman Smrž <roman.smrz@seznam.cz>2026-08-05 20:35:54 +0200
commit0efd90e5f01996ceb01f5a2889f9e2986322c371 (patch)
tree329aef1383154d7b2eeb2deca1f3522058284d83 /main/Main.hs
parent9fe388f9172717cf0ebfd223e122506725a31542 (diff)
Fix state consistency in MonadHead instacesHEADmaster
Diffstat (limited to 'main/Main.hs')
-rw-r--r--main/Main.hs6
1 files changed, 4 insertions, 2 deletions
diff --git a/main/Main.hs b/main/Main.hs
index 8d135d5..604d58f 100644
--- a/main/Main.hs
+++ b/main/Main.hs
@@ -628,8 +628,10 @@ instance MonadStorage CommandM where
instance MonadHead LocalState CommandM where
updateLocalHead f = do
- h <- gets csHead
- (Just h', x) <- maybe (fail "failed to reload head") (flip updateHead f) =<< reloadHead h
+ h <- maybe (fail "failed to reload head") return =<< reloadHead =<< gets csHead
+ ( Just h', x ) <- updateHead' h $ \h' -> do
+ modify $ \s -> s { csHead = h' }
+ f (headStoredObject h')
modify $ \s -> s { csHead = h' }
return x