haskell代写

ECS713 Group project

ECS713 Functional Programming Group Project

App using HTTP requests and database

Groups of three
Due Date:
Friday 14th December 2018

Summary: This is a group project. Groups should consist of exactly three students. During this project your group will implement a Haskell program for harvesting information from the Web and saving it on a database. The main tasks can be summarised as follows:

  1. Choose a website which contains some data of interest. This could be anything you like, e.g. football scores, weather or crime data, house prices, news items, movie details, etc. Write a module that downloads the document (HTML, CSV, XML or JSON) and extracts the data from the document converting it into appropriate custom Haskell data types.
  2. Write a module that saves/retrieves data from/to a database using again the appropriate Haskell data types.
  3. Write a module that generates a JSON representation of your Haskell data and writes to a file. Combine this with the DB access functions so that it is possible to dump the database into a JSON file.
  4. Generate haddock documentation for your project.
  5. Write a two page report explaining what your app does, how to run it, and justify any design choices you have had to make.

Extra modules needed: For this project you will be using extra Haskell modules for database access and HTTP requests. You should manage your project’s dependencies with the stack tool, using one of the latest LTS available, e.g.

https://www.stackage.org/lts-12.18

HTTP requests: In lts-12.18 there are several libraries for making HTTP requests, e.g. wreq, HTTP-4000 or http-conduit (which supports HTTPS).

Database access: In lts-12.18 there are several libraries for sqlite database access, e.g., direct-sqlite, simplest-sqlite, or sqlite-simple.

The Project: For the project you should:

  • choose a page or file that is available on the Web
  • write a program that
    • ✦  downloads the HTML page or makes API requests for XML/JSON data
    • ✦  parses the response to extract some information
    • ✦  convert this information into appropriate Haskell data types
    • ✦  stores that information on a database from the Haskell data types
    • ✦  uses that information to answer queries from the user
      You can choose which pages to work on, and which information is to be extracted. These should be specified in a few paragraphs at the beginning of your report.
      A basic project consists of:
      • A database with at least two tables, with some relationship between them (e.g. one-to- many or many-to-many).
      • Each table with at least three columns/fields.
      • A program split into four modules
      E. Robinson and P. Oliva Queen Mary University of London

ECS713 Functional Programming Group Project

  • ✦  one module dealing with the HTTP request
  • ✦  one module dealing with parsing the downloaded contents
  • ✦  one module dealing with the database (save and retrieve)
  • ✦  one main module
  • ✦  (you might also want to have a different module for your data types) • A typical main module should implement the requests such as
  • ✦  initialisethedatabase
  • ✦  download page/file from the web, parse it, and save obtained information on database
  • ✦  give access points for functions that query the database and show some of the saved information The Report: Write a two-page report explaining how to compile / run / use your application. Give details of what Web source you are using, and how you are extracting the information. Describe any extra features that you have chosen to implement that you think goes beyond what has been asked. Ways of Obtaining Online Data: There are two basic ways of harvesting data from the Internet:
  • A program downloads an HTML file and parses the contents of that html for relevant information. This assumes that the structure of the HTML will be fixed. If that’s not the case your program might eventually fail to work.
  • It might be that the information required is already available in a structured way as a JSON or XML file. Such data might be obtained either directly from a permanent link, or more commonly it will be available through a Web API (such as a REST API). Some examples of websites that provide APIs: Amazon, Twitter, RottenTomatoes, last.fm. Assessment criteria: The following are going to be the main assessment criteria used to grade your project:
  • Functionality (20%), code compiles and performs tasks correctly.
  • Knowledge of Haskell and structure of code (20%): Your code makes proper use of the concepts studied in the module, e.g. uses custom made data types, type classes and/ or monads. It includes type declarations of all functions, and clear and concise comments throughout the code.
  • Documentation (20%). Report is well-written, clear and concise. Project also includes haddock generated documentation.
  • Database (15%). The database is of reasonable complexity (number of tables, fields and a mix of SQL data types). Your project has a good set of database queries, including SELECT, DELETE and JOIN.
  • HTTP and parsing (15%). The information/data obtained from the web page is of reasonable complexity. Parsing of data is well-structured.
  • Extra features (10%). Your project contains features that stand out as being particularly complex, innovative, useful, etc. Assistance: See Real World Haskell Chapters 21 and 22.
    Submission: Your group should submit one zip file containing the stack project folder and the two-page report. This should be submitted on QM+ under “Group Project”.

E. Robinson and P. Oliva Queen Mary University of London