<br>module Main where<br>import Control.Concurrent.STM<br>import Control.Concurrent<br>import System.Random<br><br>type Account = TVar Int<br><br>transfer :: Account -> Account -> Int -> IO ()<br>transfer from to amount
<br> = atomically (do {deposit to amount;<br> withdraw from amount})<br><br>deposit :: Account -> Int -> STM ()<br>deposit acc amount = withdraw acc (- amount)<br><br>withdraw :: Account -> Int -> STM ()
<br>withdraw acc amount<br> = do { bal <- readTVar acc;<br> writeTVar acc (bal - amount) }<br><br> <br><br>When I try <br><br>withdraw (TVar 10) .. <br><br>I get "Not in scope: data constructor 'TVar'. OK .. "Tvar" is a class and not a Haskell data type ... so now what?
<br><br>Vasya<br><br><br>