This code compiles with an error: this pattern match clause is redundant
But this code is like the example in the book. What led to this code was when the second case "idle" was missing, things behaved like the the first case "transacting" evaluated true no matter what
s.ps was. So I added the second case just to debug that, and got the compile error, which kind of confirms it is always matching.
fun isWeekday
(x: wday): bool = case x of
| Saturday() => false | Sunday() => false | _ => true
// end of [isWeekday]
CODE
datatype pstate =
| Idle of ()
| Transacting of ()
| Hang of ()
typedef state = @{ addr= uint8, ps= pstate }
fun process (c:int, s:state) : state = let
val sn = case 0 of
| _ when ch = 'p' => let
| transacting => let
val _ = i2c_stop()
in 1 end
| idle => let
val _ = i2c_start()
in 2 end
val () = print! i
in @{ addr = s.addr, ps = idle } end