Skip to content

Commit

Permalink
Delete exercise 5
Browse files Browse the repository at this point in the history
Save it for next chapter
  • Loading branch information
feihong committed Sep 11, 2024
1 parent f5f2074 commit d00e9ab
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 34 deletions.
16 changes: 0 additions & 16 deletions docs/order-with-promo/Promo.re
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,3 @@ let _ =
// #endregion missing-sandwich-types-wildcard
ignore(buyWhat);
};

let _ =
code => {
// #region show-missing-sandwich-types
let buyWhat =
switch (code) {
| `NeedOneBurger => "at least 1 more burger"
| `NeedTwoBurgers => "at least 2 burgers"
| `NeedMegaBurger => "a burger with every topping"
| `MissingSandwichTypes(missing) =>
(missing |> Stdlib.Array.of_list |> Js.Array.join(~sep=", "))
++ " sandwiches"
};
// #endregion show-missing-sandwich-types
ignore(buyWhat);
};
21 changes: 4 additions & 17 deletions docs/order-with-promo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,7 @@ Then set the `className` of the promo code row to `Style.promo`:

Hot diggity! You've added the promo codes to your order confirmation widget,
just in time for Madame Jellobutter's International Burger Day promotions. In
the next chapter, we'll start writing a completely new app. Before that, cap off
what you've learned by doing some exercises.
the next chapter, we'll learn how to test our components.

## Overview

Expand Down Expand Up @@ -252,7 +251,8 @@ missing sandwich types when the discount can't be applied. Start by changing the

Note that the `` `MissingSandwichTypes`` variant tag now contains an argument of
`list(string)`. Make this test pass, and fix any incidental compilation errors.
(Don't worry about changing the render logic, that's the next exercise.)
(Don't worry about changing the render logic, that's a subject for the next
chapter.)


::: details Hint 1
Expand Down Expand Up @@ -316,7 +316,7 @@ let humanize =
| [] => ""
| [x] => x
| [x, y] => x ++ " and " ++ y
| [first, ...rest] => {
| [first, ...rest] =>
// fill in this part
```

Expand Down Expand Up @@ -366,19 +366,6 @@ An alternate solution would have been to add the commas in the callback to

:::

<b>5.</b> Use `ListSafe.humanize` in `Promo.make` to make the ``
`MissingSandwichTypes`` error message more human-readable.

Then change the render logic inside `Promo.make`'s `` `MissingSandwichTypes``
branch to convert the list of missing sandwich types to a comma-delimited
string:

<<< Promo.re#show-missing-sandwich-types{7-9}

Recall that we have to use `Stdlib.Array.of_list` instead of `Array.of_list`
because our custom `Array` module takes precedence.


-----

View [source
Expand Down
2 changes: 1 addition & 1 deletion docs/poly-to-normal-variant/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ feel free to leave out.

---

Phew! You refactored the `discount` reactive variable to use a normal variant
Phew! You refactored the `discount` derived variable to use a normal variant
instead of a polymorphic variant. The code changes were fairly minimal, but to
understand what was happening, it was necessary to learn the basics of type
constructors and type variables. In the next sections, we'll set types and other
Expand Down

0 comments on commit d00e9ab

Please sign in to comment.