Section 2.4 of the Haskell 98 report says

  "Compilers that offer warnings for unused identifiers are encouraged
  to suppress such warnings for identifiers beginning with underscore.
  This allows programmers to use ``_foo'' for a parameter they expect
  to be unused."

In GHC at least, a frequent idiom is the following:

  case e of

    -- ... other alternatives omitted

    other -> default_action

Here other is not free in default_action.

Unfortunately, the H98 recommended behaviour yields a warning for the
unused identifier `other' here.

The question is: should there be special syntax for `all remaining
cases' (`else', `other', or `otherwise', for example)?  This would not
require a new reserved word; it would merely require an addition to
the above recommendation that warnings be suppressed for identifiers
with this name also.

Alternatively, of course, the coding style could simply change to

  case e of
    -- ... 
    _other -> default_action

or

  case e of
    -- ... 
    _ -> default_action

The former is IMHO ugly, and the latter fails to indicate to the
reader that this is intended to match not *all* alternatives, but just
those not already matched.

--KW 8-)


Reply via email to