| > f c | (i,j) <- Just (toRect c) = ...
|
| I'm afraid this example suffers from the same problem as my "simplify"
| example did: It does not perform a test and can thus be replaced by
|
| f c = ...
| where (i,j) = toRect c
True. I can think of two non-contrived ways in which this would
not work so well. First, "c" might be got from another pattern match:
f d | Just c <- h d,
(i,j) <- toRect c
= ...
Then you couldn't use a where clause. Second, the view might often
be the maybe-like kind:
data SnocView a = Snoc [a] a
| SNil
snocView :: [a] -> SnocView a
f xs | Snoc ys y <- snocView xs
= ...
You could instead give snocView the type
snocView :: [a] -> Maybe ([a], a)
but I find that less appealing somehow. But as we keep saying, you certainly
can code up everything in terms of everything else.
Simon