Beginning Haskell by Alejandro Serrano Mena

Beginning Haskell by Alejandro Serrano Mena

Author:Alejandro Serrano Mena
Language: eng
Format: epub, mobi, pdf
ISBN: 9781430262503
Publisher: Apress


payByCash :: Eq a => a -> Integer -> TVar Integer -> TVar [(a,Integer)] -> STM ()

payByCash = ... -- code that asks for cash omitted

In EXERCISE 8-2 you can use your knowledge of transactions to build a Time Machine system.

EXERCISE 8-2. TRAVELING THROUGH TIME

The Time Machine Store also provides the service of time traveling. However, there are some restrictions that customers must abide by: at most n people can be traveling at the same moment (because the company only owns n time machines) and by no means should two people be on the same year at the same time.

Develop a small application where customers are simulated by different threads, and the restrictions are always satisfied via a careful use of the stm library. Hint: use a shared TVar for saving the years that people are traveling to, and retry to block customers for traveling without satisfying the rules.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.