Jump to content

Result type

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by 69.191.241.59 (talk) at 22:02, 1 August 2016. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In functional programming, a result type is a Monadic type holding a returned value or an error code. They provide an elegant way of handling errors, without resorting to exception handling; when a function that may fail returns a result type, the programmer is forced to consider success or failure paths, before getting access to the expected result; this eliminates the possibility of an erroneous programmer assumption.

Examples

  • in Rust, the standard library provides the Result<T,E> type to handle return values or error codes, expanding on the functionality of the Option<T> type.

See also