LINUX.ORG.RU

История изменений

Исправление qnikst, (текущая версия) :

{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent.STM
import Control.Exception

main = print =<< (atomically $ do
    x <- newTVar 10
    catchSTM (inner x) (\(e::SomeException) -> handle x))
  where
    handle x = fmap (+1) $ readTVar x
    inner x = do
      writeTVar x 15
      throwSTM (userError "Q")

qnikst@qwork ~ $ runhaskell 22.hs
11

похоже, я таки прав.

Исходная версия qnikst, :

{-# LANGUAGE ScopedTypeVariables #-}
import Control.Concurrent.STM
import Control.Exception

main = print =<< (atomically $ do
    x <- newTVar 10
    catchSTM (inner x) (\(e::SomeException) -> handle x))
  where
    handle x = fmap (+1) $ readTVar x
    inner x = do
      writeTVar x 15
      throwSTM (userError "Q")

qnikst@qwork ~ $ runhaskell 22.hs
11

похоже, я таки прав.