this is a project of a film database. I have to display the title of the film and the user's rating.

With this code I'm able to display all the films that the user's has rated (along with the other users ratings).

```
-- Types
type Title = String
type Director = String
type Year = Int
type Mark = Int
type Rating = (String, Int)

-- Define Film type here
type Film = (Title, Director, Year, [Rating])

-- Define database type here
type Database = [Film]

testDatabase :: [Film]
testDatabase =
  [("Casino Royale", "Martin Campbell",  2006, [("Garry",8),("Dave", 0)])
  ,("Blade Runner",  "Ridley Scott",     1982, [("Amy",  5),("Dave", 9)])
  ,("The Fly",       "David Cronenberg", 1986, [("Fred", 7),("Dave", 4)])
  ]

hasRated :: [Rating] -> String -> Bool
hasRated [] givenUsername = False
hasRated ((name, rate):xs) givenUsername
            | name == givenUsername && rate > 0 = True
            | otherwise = hasRated xs givenUsername 

listRatedFilms :: String -> Film -> Bool
listRatedFilms givenUsername (t, d, y, r) = hasRated r givenUsername

displayFilmsRating :: String -> Database -> String
displayFilmsRating username database = 
  displayRatedFilm (filter (listRatedFilms username) database)

displayRatedFilm :: Database -> String
displayRatedFilm database = concat(map displayRatedFilms database)

displayRatedFilms :: Film -> String
displayRatedFilms (title, director, year, rating) = 
  "\nTitle: " ++ title ++ "\nRating: " ++ (show rating) ++ "\n"

```

How is possible to get the rating of the user of each movie separated.

Current unwanted result:

```
ghci> displayFilmsRating "Zoe" testDatabase

Title: Hugo
Rating: [("Sam",4),("Wally",3),("Zoe",4),("Liz",7)]

Title: Vertigo
Rating: [("Bill",7),("Emma",5),("Zoe",9),("Olga",6),("Tim",10)]

Title: Lincoln
Rating: [("Ian",3),("Sam",7),("Wally",3),("Zoe",4),("Liz",7),("Megan",4)]

```

Wanted reuslt:

> 
> Title: Titanic  
> 
>  Rating: 7
> 
> 
> Title: Avatar  
> 
>  Rating: 7
> 
> 
> 

All other Users Rating should be gone somehow!

**Update:**

I made another attempt but no luck. You might take a look and give some idea if you like:

```
listRatedFilms :: String -> Film -> Bool
listRatedFilms givenUsername (t, d, y, r) = hasRated r givenUsername

hasRated :: [Rating] -> String -> Bool
hasRated [] givenUsername = False
hasRated ((name, rate):xs) givenUsername
            | name == givenUsername && rate > 0 = True
            | otherwise = hasRated xs givenUsername 

-- This new function returns a database, whith all the films that the user has rated
findLikedFilms :: String -> Database -> Database
findLikedFilms username database = filter (listRatedFilms username) database

-- these functions returns the rating of the user's
takeMark :: [Rating] -> String -> Int
takeMark [] givenUsername = 0
takeMark ((name, rate):xs) givenUsername
            | name == givenUsername && rate > 0 = rate
            | otherwise = takeMark xs givenUsername 

takeMarks :: String -> Film -> Int
takeMarks givenUsername (t, d, y, r) = takeMark r givenUsername 
--

displayFilmsRating :: String -> Database -> String
displayFilmsRating username database = map (findLikedFilms (username database)) (takeMarks (username database))

displayRatedFilms :: Database -> Int -> String
displayRatedFilms database mark = concat(map (displayRatedFilmtest database) mark)

displayRatedFilmtest :: Film -> Int -> String
displayRatedFilmtest (title, director, year, rating) mark = "\nTitle: " ++ title ++ "\nRating: " ++ (show mark) ++ "\n"

```

Somehow I have to write the functions displayFilmsRating and displayRatedFilms in a way that puts everything together and returns to the displayRatedFilmtest function the film and the mark.

With these functions I'm able to get the results I need separately but I've no luck to put them together in a function.

**Last Edit:**
I trying to display the results of displayRatedFilmsForUser through the displayRatedFilm functions but when I change the output of displayRatedFilmsForUser from IO() to string getting an error and its asking for IO(). when its IO() its working fine.
Whats going wrong with my modification?

```
displayRatedFilmsForUser :: String -> Database -> IO()
displayRatedFilmsForUser username database = mapM_ (showResult) $ findLikedFilms username database
  where
    showResult film@(t, _, _, rs) = displayRatedFilm t (takeMarks username film)

displayRatedFilm :: Title -> Mark -> String
displayRatedFilm title mark = "\nTitle: " ++ (show title) ++ "\nRating: " ++ (show mark) ++ "\n"

```