Question: Task: You will implement a Haskell stack app that uses threads and concurrent computation . Your task to simulate a social network. The main program

Task: You will implement a Haskell stack app that uses threads and concurrent computation. Your task to simulate a social network. The main program should spawn ten user threads, and each of these threads model a user in the social network. The customers should then (at random intervals) choose one of the other users (at random) and send a random message to that user.

  1. Your project should define an appropriate Haskell data type User, which should include their username, and a Message type to keep track of messages between users.
  2. Your project should also contain a main thread which creates ten users (ten values of type User), and spawns ten threads, one for each of these users.
  3. Each user thread should behave as follows: at random time intervals, the thread should select one of the other users at random, and send a random message to that user.
  4. Your system should simulate 100 messages, and then terminate and output the final count of how many messages each user received.
  5. Make sure each definition includes haddock style comments.
  6. You should also write a one-page report, detailing any issues you have faced, and justifying any design decisions youve had to make (e.g. how you chose to model the User and Message types, and how did you choose which MVars to use).

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!