Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions

Question

Which personal relationships influenced you the most?

Answered: 1 week ago

Question

What were your most important educational experiences?

Answered: 1 week ago