Partial functions

From HaskellWiki
Revision as of 11:28, 5 June 2012 by Lemming (talk | contribs) (basic definition)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

A partial function is a function that is not defined for all possible arguments of the specified type. Examples in the Haskell standard library are:

  • head, tail: undefined for empty lists
  • (!!): undefined if the index is at least as big as the list length
  • div: undefined if the divisor is zero

The opposite is a total function.

There are methods to avoid the use of partial functions.