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