Your task is to write a program in Haskell for an Instagram followers data website
Ask Expert

Be Prepared For The Toughest Questions

Practice Problems

Your task is to write a program in Haskell for an Instagram followers data website

Your task

Your task is to write a program in Haskell for an Instagram followers data website that lets administrators add new local artist, update their current numbers of followers, archive the end of year number of followers, and display the details of follower numbers for the artists. The site maintains a “database” (a textfile) of some local artists’ Instagram followers’ data; each record of which gives a local artists’ ID, name, gender, latest updated followers, date of latest update and past years end-of-year followers numbers. 

You should begin by developing purely functional code to cover the core functionality, and then add to this the functions/actions that will comprise the program’s user interface. You may make your own assumptions should there be any grey area in the scenario given. 

Core functionality 

The program should include pure (non-I/O) functions that perform the following: 

(i) add a new local artist with their current number of followers to the database  

(ii) show all local artists with their current number of followers in the database  

(iii) show all local artists that were last updated on a certain date 

(iv) show all local artists whose account has recorded end-of-year numbers of followers for 2017  

(v) give the average number of followers the local artists have based on their respective last recorded number of followers. 

(vi) give the names of the local artists that have more than a certain number of followers in a certain year   

(vii) allow the administrator to record an end-of-year number of followers for a local artist (note that an existing end-of-year number may be overridden with the newest update for the same year)  

(viii) give all local artists whose average number of followers over past years since they set up the Instagram account is between two given values (inclusive), sorted in descending order of number of followers. 

Note that for functions (ii), (iii), (iv) and (viii), the well-formatted string-valued results should include each local artist ID, Mr or Ms, Name, followers number and last update date. Use the printf function from the Text.Printf module to achieve nice formatting of floating-point numbers (e.g., printf "%3.2f" 2.1234 is "2.12"). 

I recommend that you attempt the above items in order – the first few should be easier than those at the end. If you can’t complete all eight items of functionality, try to ensure that those parts that you have attempted are correct and as well-written as possible. Ensure also that every segment of code you write is appropriately documented. Hints. Begin by copying and renaming the template.hs file from Moodle; your code should be developed within this file. Your first task will be to decide on a data representation for artist Instagram follower data. The database of Instagram can then be of type [Artist]. Now, for example, the functions to perform items (i) and (ii) above might have the types: 

addArtist :: String -> String -> String -> String -> [Artist]  -> [Artist]  ArtistAsString :: [Artist] -> String 

where addArtist id name gender instagram database returns a modified version of database with a new artist (with the given ID, name, gender) with, 0 follower, today date in yyyy-mm-dd format, and with no previous years data) added, and artistAsString database gives a string which, when output using putStrLn, is nicely formatted and multi-line. You may find it useful to define a few additional “helper” functions to aid in the writing of the program. You may also find functions in the Data.List and Data.Set modules useful. 

Test data. There is a file instagram.txt containing test data on Moodle. You should copy and edit this data so that it is a valid value of type [Artist] given your particular Artist type definition. Include this data in your program file as follows: 

testDatabase :: [Artist]  

testDatabase = [ ... the test data ... ] 

to allow for easy testing as you develop the program’s functionality. It is this data that will be used to test your program in your report, so it is important that you include it fully and accurately. You should prepare a demo function (the structure of which is supplied in the template.hs program). You should replace all the text in this function by corresponding expressions (this has essentially been done for you for demo 2). We will test your codes with our database to tally with your report screen output dumps. 

User Interface and User Guide 

Your program should provide a textual menu-based user interface to the above functionality, using the I/O facilities provided by Haskell. The user interface should be as robust as possible (it should behave appropriately given invalid input) and for those functions that give results, the display of these results should be well formatted. (This formatting should be handled by purely functional code, as detailed above.)  

Your program should include a main function (of type IO ()) that provides a single starting point for its execution. When the program begins, the database should be loaded from a text-file, and all the films should be displayed (i.e. operation (ii) performed). It should then ask the user’s name; this name should then be used for functions (iv), (vi) and (viii). After the user enters their name, your program should present the menu for the first time. 

Only when the user chooses to exit the program should the database be written back to this file (at no other times should files be used). Saving and loading can be implemented in a straightforward manner using the writeFile and readFile functions together with show and read (which convert data to and from strings). 

Code quality

We will award marks based on your code’s completeness, readability and efficient use of Haskell’s functional programming and I/O facilities. Good use of powerful functional programming concepts (e.g. higher-order functions) to achieve concise readable code will be rewarded.

Hint
ComputerHaskell is a functional programming language. So, in this language, there is no need to tell the computer what needs to be done and tells what the stuff is. It is a general-purpose, which is typed statically, purely functional programming language with type inference and lazy evaluation. It is also designed for research, teaching, and the industrial application. This language has also pion...

Know the process

Students succeed in their courses by connecting and communicating with
an expert until they receive help on their questions

1
img

Submit Question

Post project within your desired price and deadline.

2
img

Tutor Is Assigned

A quality expert with the ability to solve your project will be assigned.

3
img

Receive Help

Check order history for updates. An email as a notification will be sent.

img
Unable to find what you’re looking for?

Consult our trusted tutors.

Developed by Versioning Solutions.