# HG changeset patch # User wenzelm # Date 1185299073 -7200 # Node ID e0358fac0541b3b039ed64588b63fade3fe0b182 # Parent 9e7e1e309ebd58a67eebb74b4435bac98ced8e34 Runtime exceptions as values (from library.ML); diff -r 9e7e1e309ebd -r e0358fac0541 src/Pure/ML-Systems/exn.ML --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Pure/ML-Systems/exn.ML Tue Jul 24 19:44:33 2007 +0200 @@ -0,0 +1,28 @@ +(* Title: Pure/ML-Systems/exn.ML + ID: $Id$ + Author: Makarius + +Runtime exceptions as values. +*) + +structure Exn = +struct + +datatype 'a result = + Result of 'a | + Exn of exn; + +fun get_result (Result x) = SOME x + | get_result _ = NONE; + +fun get_exn (Exn exn) = SOME exn + | get_exn _ = NONE; + +fun capture f x = Result (f x) handle e => Exn e; + +fun release (Result y) = y + | release (Exn e) = raise e; + +exception EXCEPTIONS of exn list * string; + +end;