Switchable class seen in the type signatures, and its necessary instances are
defined internally by this module. The
switch statement can be encoded for numeric,
boolean, and string scrutinees.
switch, a value can be returned from JSMW
the second example). All expressions matching case labels must return values of the same
Below are examples of
switch statements encoded in JSMW.
Encode a case label. The first (left) argument is a literal describing
the value of the label. Note that the left argument must be a Haskell
True rather than
true. The second (right) argument is a JSMW monadic
expression matching the label.
Break statements are inserted automatically
(that is, fall-through case labels are not permitted).
default: case label, that is, what action should be taken if none
of the case labels matches the scrutinee.
-->, JSMW monadic expression should be of the same type.
Also note that if no case label matches the scrutinee value, and no default
label has been defined, an exception will be thrown showing the scrutinee
name that did not match.