[Haskell-cafe] encountering another STM problem .. "teething problems" ; ^)

Galchin Vasili vigalchin at gmail.com
Sun Dec 30 01:09:59 EST 2007


Hello,

     Here is a code snippet:
type Resource = TVar Int

putR :: Resource -> Int -> STM ()
putR r i = do { v <- readTVar r;
                writeTVar r (v + i) }

getR :: Resource -> Int -> STM ()
getR r i = do { v <- readTVar r;
                if (v < i) then retry
                else writeTVar r (v-i)}

createR :: Int -> STM (Resource)
createR i = newTVar i

main = do {atomic (r <- (createR 1); putR r 1)}

Strangely I am not getting a type error rather a syntax on the "<-" in main.
??

Kind regards, Vasya
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20071230/42fa3138/attachment.htm


More information about the Haskell-Cafe mailing list