Content deleted Content added
m →Vending machine: spacing |
→Vending machine: correction |
||
Line 25:
data Buttons = BCoffee | BTea | BCancel;
type Int = int 32 ;
exception EFakeCoin :: string ;▼
▲exception EFakeCoin :: (Int, string) ;
box coffee
Line 37 ⟶ 39:
match
-- * wildcards for unfilled outputs, and unconsumed inputs
( coin, *, v) -> let v’ =
in ( *, v’, *, show v’)
Line 47 ⟶ 49:
handle
EFakeCoin (v, msg) -> ( *,
| TimeOut () -> (*, *, *, "maybe content exhausted, call service!")
| HeapOverflow () -> (*, *, *, "error: heap limit exceeded")
Line 53 ⟶ 55:
;
incrementCredit coin v =
case coin of
Nickel -> v + 5
Dime -> v + 10
Fake -> raise EFakeCoin (v, "coin rejected")
vend drink cost v =
|