ion
```

<br>

```scala
def orderWorkflow(orderId: Int, items: List[Item]): IO[Order] =
  createOrder(orderId)
   .addItems(items)       // IO[Order]
   .`flatMap`(_.checkout)   // IO[Order]
```
]

---
# IO is too powerful

<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"))
```
]

---
# Functional error handling

<img