Discarding values

Contents
  • Enabling warnings
  • Unused local binds
  • Unused matches
  • Unused do bind

Using an underscore as the first character in a value-level identifier conventionally signifies that the value is unused. Although the Haskell language specification is technically silent about this convention, it is informally enshrined in Haskell Report:Haskell 2010, section 2.4: Identifiers and Operators

Compilers that offer warnings for unused identifiers are encouraged to suppress such warnings for identifiers beginning with underscore.

And indeed this is what GHC does. The compiler will issue a warning about an unused definition because it is likely a sign of a mistake.

Sign up for access to the full page, plus the complete archive and all the latest content.