src/Pure/General/exn.ML
changeset 78674 88f47c70187a
parent 78673 90b12b919b5f
child 78681 38fe769658be
equal deleted inserted replaced
78673:90b12b919b5f 78674:88f47c70187a
    15 sig
    15 sig
    16   include BASIC_EXN
    16   include BASIC_EXN
    17   val polyml_location: exn -> PolyML.location option
    17   val polyml_location: exn -> PolyML.location option
    18   val reraise: exn -> 'a
    18   val reraise: exn -> 'a
    19   datatype 'a result = Res of 'a | Exn of exn
    19   datatype 'a result = Res of 'a | Exn of exn
       
    20   val is_res: 'a result -> bool
       
    21   val is_exn: 'a result -> bool
    20   val get_res: 'a result -> 'a option
    22   val get_res: 'a result -> 'a option
    21   val get_exn: 'a result -> exn option
    23   val get_exn: 'a result -> exn option
    22   val capture: ('a -> 'b) -> 'a -> 'b result
    24   val capture: ('a -> 'b) -> 'a -> 'b result
    23   val release: 'a result -> 'a
    25   val release: 'a result -> 'a
    24   val map_res: ('a -> 'b) -> 'a result -> 'b result
    26   val map_res: ('a -> 'b) -> 'a result -> 'b result
    59 (* exceptions as values *)
    61 (* exceptions as values *)
    60 
    62 
    61 datatype 'a result =
    63 datatype 'a result =
    62   Res of 'a |
    64   Res of 'a |
    63   Exn of exn;
    65   Exn of exn;
       
    66 
       
    67 fun is_res (Res _) = true
       
    68   | is_res _ = false;
       
    69 
       
    70 fun is_exn (Exn _) = true
       
    71   | is_exn _ = false;
    64 
    72 
    65 fun get_res (Res x) = SOME x
    73 fun get_res (Res x) = SOME x
    66   | get_res _ = NONE;
    74   | get_res _ = NONE;
    67 
    75 
    68 fun get_exn (Exn exn) = SOME exn
    76 fun get_exn (Exn exn) = SOME exn