3 ms·
How does ruby prevent you from doing non-transactional things between 'do' and 'end'?
by mrkeen 3y ago
How does ruby prevent you from doing non-transactional things between 'do' and 'end'?
- slondr 3y agoThe same way you would be prevented from doing non-transactional things between calls to transaction.start() and transaction.end()
- mrkeen 3y agoWhen I write this: someTransaction = do incrementCounter writeFile "foo.txt" "bar" decrementCounter I get this: src/Lib.hs:11:5: error: • Couldn't match type ‘IO’ with ‘STM’ Expected: STM () Actual: IO () • In a stmt of a 'do' block: writeFile "foo.txt" "bar" In the expression: do incrementCounter writeFile "foo.txt" "bar" decrementCounter In an equation for ‘someTransaction’: someTransaction = do incrementCounter writeFile "foo.txt" "bar" decrementCounter | 11 | writeFile "foo.txt" "bar" | ^^^^^^^^^^^^^^^^^^^^^^^^^