src/Pure/System/process_result.ML
author wenzelm
Mon, 22 Feb 2021 16:58:56 +0100
changeset 73280 a96944cbaf7d
parent 73278 7dbae202ff84
child 73281 22417b631453
permissions -rw-r--r--
tuned;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
73275
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     1
(*  Title:      Pure/System/process_result.scala
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     2
    Author:     Makarius
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     3
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     4
Result of system process.
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     5
*)
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     6
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     7
signature PROCESS_RESULT =
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     8
sig
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
     9
  type T
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    10
  val make:
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    11
   {rc: int,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    12
    out_lines: string list,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    13
    err_lines: string list,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    14
    timing: Timing.timing} -> T
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    15
  val rc: T -> int
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    16
  val out_lines: T -> string list
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    17
  val err_lines: T -> string list
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    18
  val timing: T -> Timing.timing
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    19
  val out: T -> string
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    20
  val err: T -> string
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    21
  val ok: T -> bool
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    22
  val check: T -> T
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    23
end;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    24
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    25
structure Process_Result: PROCESS_RESULT =
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    26
struct
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    27
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    28
abstype T =
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    29
  Process_Result of
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    30
   {rc: int,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    31
    out_lines: string list,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    32
    err_lines: string list,
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    33
    timing: Timing.timing}
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    34
with
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    35
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    36
val make = Process_Result;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    37
fun rep (Process_Result args) = args;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    38
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    39
val rc = #rc o rep;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    40
val out_lines = #out_lines o rep;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    41
val err_lines = #err_lines o rep;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    42
val timing = #timing o rep;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    43
73280
wenzelm
parents: 73278
diff changeset
    44
end;
wenzelm
parents: 73278
diff changeset
    45
73277
0110e2e2964c clarified signature: always trim_line of Process_Result.out/err, uniformly in ML and Scala;
wenzelm
parents: 73275
diff changeset
    46
val out = trim_line o cat_lines o out_lines;
0110e2e2964c clarified signature: always trim_line of Process_Result.out/err, uniformly in ML and Scala;
wenzelm
parents: 73275
diff changeset
    47
val err = trim_line o cat_lines o err_lines;
73275
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    48
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    49
fun ok result = rc result = 0;
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    50
73278
7dbae202ff84 clarified signature: Isabelle_System.bash_process is strict and thus cannot check for interrupt_return_code;
wenzelm
parents: 73277
diff changeset
    51
fun check result = if ok result then result else error (err result);
73275
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    52
f0db1e4c89bc clarified signature, following Isabelle/Scala;
wenzelm
parents:
diff changeset
    53
end;