Concurrent Haskell

Its two main underlying concepts are: Built on this is a set of useful concurrency and synchronizing abstractions[2] such as unbounded channels, semaphores and sample variables.

In the IO monad, this might look like: This causes problems in concurrent situations where multiple transfers might be taking place on the same account at the same time.

For instance, locks can be placed around modifications to an account to ensure that credits and debits occur atomically.

In Haskell, locking is accomplished with MVars: Using such procedures will ensure that money will never be lost or gained due to improper interleaving of reads and writes to any individual account.

The above implementation will make sure that no other transactions interfere with the variables it is using (from and to) while it is executing, allowing the developer to be sure that race conditions like that above are not encountered.