A thin effect layer keeps the program’s core pure while an outer layer performs or handles effects. Instead of submitting a charge while constructing it, code can create a Charge as a value and defer its processing to the boundary. section 1.1.2
Coffee purchase
A coffee operation returns both Coffee and Charge. The core computes these values without processing payment; an outer layer later submits the Charge to an external system. Similar structure can contain local mutation or file writes when surrounding code cannot observe them. section 1.1.2
class Cafe:
def buyCoffee(cc: CreditCard): (Coffee, Charge) = #1
val cup = Coffee()
(cup, Charge(cc, cup.price)) #2
Inspect the coffee example that separates purchase construction from charge handling. section 1.1.2
