Question: I need to create some functions in Haskell. The types are: type Person = String type Book = String type Database = [ (Person, [Book])

I need to create some functions in Haskell. The types are:

type Person = String

type Book = String type

Database = [ (Person, [Book]) ]

The functions are:

books :: Database -> Person -> [Book] #books returns a list of the books a person is borrowing

borrowers :: Database -> Book -> [Person] #borrowers returns a list of people who are borrowing a book

borrowed :: Database -> Book -> Bool #borrowed checks if a book is checked out

numBorrowed :: Database -> Person -> Int #numBorrowed checks how many books a person has checked out

makeLoan :: Database -> Person -> Book -> Database #makeLoan adds a book to a persons list of books updates the database

returnLoan :: Database -> Person -> Book -> Database # returnLoan removes a book from a persons list of books updates the database

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!