File: outcome.ml

package info (click to toggle)
ocaml 5.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 44,372 kB
  • sloc: ml: 370,196; ansic: 52,820; sh: 27,396; asm: 5,462; makefile: 3,679; python: 974; awk: 278; javascript: 273; perl: 59; fortran: 21; cs: 9
file content (52 lines) | stat: -rw-r--r-- 1,054 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
(*********************************************)
(* Outcomes, _i.e._ final values of test run *)
(*********************************************)

module type T = sig
  type t
  val compare : t -> t -> int
  val pp : t -> string
end

module Int = struct
  type t = int
  let compare = Int.compare
  let pp = Printf.sprintf "%d"
end

module type Allow = sig val allowed : bool end

module
  Make(T0:T)(T1:T)
    (N:
       sig
         val name : string
         val tag0 : string
         val tag1 : string
         val ok : T0.t -> T1.t -> bool
       end)
    (A:Allow) =
  struct

    type t = { r0 : T0.t ; r1 : T1.t; }

    let compare k1 k2 = match T0.compare k1.r0 k2.r0 with
      | 0 -> T1.compare k1.r1 k2.r1
      | r -> r

    let ok k = N.ok k.r0 k.r1

    let allowed = A.allowed

    let name = N.name

    let make r0 r1 = { r0; r1; }

    let pp chan k =
      Printf.fprintf chan "%s=%s; %s=%s;"
        N.tag0 (T0.pp k.r0) N.tag1 (T1.pp k.r1)

  end

module OK = struct let allowed = true end
module NO = struct let allowed = false  end