

---
# Solution 2: IO

<br>

.eighty-two-left[
```scala
def checkout(order: Order): IO[Order] =
  if (order.status != "Draft")   IO.fail(InvalidStatus(order.status))
  else if (order.basket.isEmpty) IO.fail(EmptyBasket)
  else
    `IO`(order.copy(status = "Checkout"))
```
]

---
# Solution 2: IO

<br>

.eighty-two-left[
```scala
def checkout(order: Order): `IO[Order]` =
  if (order.status != "Draft")   IO.fail(InvalidStatus(order.status))
  else if (order.basket.isEmpty) IO.fail(EmptyBasket)
  else
    IO(