|
| 1 | +# Instructions |
| 2 | + |
| 3 | +In this exercise, it's Valentine's day and you are planning what to do with your partner. Your partner has lots of ideas, and is asking you to rate the ideas, in order to find the best activity. |
| 4 | + |
| 5 | +The following ideas are proposed by your partner: |
| 6 | + |
| 7 | +- Playing a board game |
| 8 | +- Chill out |
| 9 | +- Watch a movie |
| 10 | +- Go to a restaurant |
| 11 | +- Take a walk |
| 12 | + |
| 13 | +You have six tasks to help choose your Valentine's day activity. |
| 14 | + |
| 15 | +## 1. Define the approval |
| 16 | + |
| 17 | +For each idea your partner proposes, you respond with one of three options: yes, no or maybe. |
| 18 | + |
| 19 | +Define the `Approval` algebraic data type to represent these options for the following three cases: `Yes`, `No` or `Maybe`. |
| 20 | + |
| 21 | +## 2. Define the cuisines |
| 22 | + |
| 23 | +Your partner has selected two possible restaurants: one based on Korean cuisine and the other based on Turkish cuisine. |
| 24 | + |
| 25 | +Define the `Cuisine` algebraic data type to represent these restaurants as the following two cases: `Korean` or `Turkish`. |
| 26 | + |
| 27 | +## 3. Define the movie genres |
| 28 | + |
| 29 | +There are tons of movies to choose from, so to narrow things down, your partner also lists their preferred genre. |
| 30 | + |
| 31 | +Define the `Genre` algebraic data type to represent the following genres cases: `Crime`, `Horror`, `Romance` or `Thriller`. |
| 32 | + |
| 33 | +## 4. Define the activity |
| 34 | + |
| 35 | +As mentioned, your partner has come up with five possible activities: playing a board game, chill out, watch a movie, go to a restaurant and taking a walk. |
| 36 | + |
| 37 | +Define the `Activity` algebraic data type to represent these activity types: |
| 38 | + |
| 39 | +- `BoardGame`: no associated data. |
| 40 | +- `Chill`: no associated data. |
| 41 | +- `Movie`: has its `Genre` as associated data. |
| 42 | +- `Restaurant`: has its `Cuisine` as associated data. |
| 43 | +- `Walk`: has an `Int` representing the number of kilometers to walk as associated data. |
| 44 | + |
| 45 | +## 5. Rate the activity |
| 46 | + |
| 47 | +Finally, you're ready to rate your partner's ideas. This is how you feel about your partner's idea: |
| 48 | + |
| 49 | +- Playing a board game: no. |
| 50 | +- Chill out: no. |
| 51 | +- Watch a movie: yes if it is a romantic movie; otherwise, no. |
| 52 | +- Go to a restaurant: yes if the cuisine is Korean, maybe if it is Turkish. |
| 53 | +- Take a walk: yes if the walk is less than three kilometers; maybe if it is between three and five kilometers; otherwise, no. |
| 54 | + |
| 55 | +Implement a function named `rateActivity` that takes an `Activity` value and returns the `Approval` based on the above sentiments. For example: |
| 56 | + |
| 57 | +```haskell |
| 58 | +rateActivity (Restaurant Turkish) |
| 59 | +-- -> Maybe |
| 60 | +``` |
0 commit comments