Errors as Data Values

  • Tero Hasu University of Bergen
  • Magne Haveraaen University of Bergen

Abstract

A “thrown” exception is a non-local side effect that complicates static reasoning about code. Particularly in functional languages it is fairly common to instead propagate errors as ordinary values. The propagation is sometimes done in monadic style, and some languages include syntactic conveniences for writing expressions in that style. We discuss a guarded- algebra-inspired approach for integrating similar, implicit error propagation into a language with “normal” function application syntax. The presented failure management approach accommodates language designs with all- referentially-transparent expressions. It furthermore supports automatically checking data invariants and function pre- and post-conditions, recording a trace of any due-to-an-error unevaluateable or failed expressions, and in some cases retaining “bad” values for potential use in recovering from an error.
Published
2016-11-22
Section
Artikler