src/Pure/Isar/runtime.ML
changeset 53709 84522727f9d3
parent 52686 f4871fe80410
child 56265 785569927666
equal deleted inserted replaced
53708:92aa282841f8 53709:84522727f9d3
    15   type exn_info = {exn_position: exn -> Position.T, pretty_exn: exn -> Pretty.T}
    15   type exn_info = {exn_position: exn -> Position.T, pretty_exn: exn -> Pretty.T}
    16   type error = ((serial * string) * string option)
    16   type error = ((serial * string) * string option)
    17   val exn_messages_ids: exn_info -> exn -> error list
    17   val exn_messages_ids: exn_info -> exn -> error list
    18   val exn_messages: exn_info -> exn -> (serial * string) list
    18   val exn_messages: exn_info -> exn -> (serial * string) list
    19   val exn_message: exn_info -> exn -> string
    19   val exn_message: exn_info -> exn -> string
    20   val debugging: ('a -> 'b) -> 'a -> 'b
    20   val debugging: (exn -> string) -> ('a -> 'b) -> 'a -> 'b
    21   val controlled_execution: ('a -> 'b) -> 'a -> 'b
    21   val controlled_execution: (exn -> string) -> ('a -> 'b) -> 'a -> 'b
    22   val toplevel_error: (exn -> unit) -> ('a -> 'b) -> 'a -> 'b
    22   val toplevel_error: (exn -> unit) -> ('a -> 'b) -> 'a -> 'b
    23 end;
    23 end;
    24 
    24 
    25 structure Runtime: RUNTIME =
    25 structure Runtime: RUNTIME =
    26 struct
    26 struct
   135   | msgs => cat_lines (map snd msgs));
   135   | msgs => cat_lines (map snd msgs));
   136 
   136 
   137 
   137 
   138 (** controlled execution **)
   138 (** controlled execution **)
   139 
   139 
   140 fun debugging f x =
   140 fun debugging exn_message f x =
   141   if ! debug
   141   if ! debug
   142   then exception_trace (fn () => f x)
   142   then print_exception_trace exn_message (fn () => f x)
   143   else f x;
   143   else f x;
   144 
   144 
   145 fun controlled_execution f x =
   145 fun controlled_execution exn_message f x =
   146   (f |> debugging |> Future.interruptible_task) x;
   146   (f |> debugging exn_message |> Future.interruptible_task) x;
   147 
   147 
   148 fun toplevel_error output_exn f x = f x
   148 fun toplevel_error output_exn f x = f x
   149   handle exn =>
   149   handle exn =>
   150     if Exn.is_interrupt exn then reraise exn
   150     if Exn.is_interrupt exn then reraise exn
   151     else
   151     else