package preface

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file arrow_apply.ml

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
53
54
55
56
open QCheck2

module Suite
    (R : Model.PROFUNCTORIAL)
    (P : Preface_specs.ARROW_APPLY with type ('a, 'b) t = ('a, 'b) R.t)
    (A : Model.T0)
    (B : Model.T0)
    (C : Model.T0)
    (D : Model.T0) =
struct
  module Arrow = Arrow.Suite (R) (P) (A) (B) (C) (D)
  module Laws = Preface_laws.Arrow_apply.For (P)

  let arrow_apply_1 count =
    let generator = Gen.unit
    and input = R.input (Gen.tup2 A.generator B.generator) in
    Util.test ~count (Gen.tup2 generator input) Laws.arrow_apply_1
      (fun lhs rhs ((), x) ->
        let left = lhs ()
        and right = rhs () in
        R.run_equality x (R.equal (Util.equal_pair A.equal B.equal)) left right )
  ;;

  let arrow_apply_2 count =
    let generator = R.generator A.observable B.generator
    and input =
      R.input (Gen.tup2 (R.generator B.observable C.generator) A.generator)
    in
    Util.test ~count (Gen.tup2 generator input) Laws.arrow_apply_2
      (fun lhs rhs (p, x) ->
        let pro = R.lift p
        and x = R.map_input (fun (p, x) -> (R.lift p, x)) x in
        let left = lhs pro
        and right = rhs pro in
        R.run_equality x (R.equal C.equal) left right )
  ;;

  let arrow_apply_3 count =
    let generator = R.generator A.observable B.generator
    and input =
      R.input (Gen.tup2 (R.generator C.observable A.generator) C.generator)
    in
    Util.test ~count (Gen.tup2 generator input) Laws.arrow_apply_3
      (fun lhs rhs (p, x) ->
        let pro = R.lift p
        and x = R.map_input (fun (p, x) -> (R.lift p, x)) x in
        let left = lhs pro
        and right = rhs pro in
        R.run_equality x (R.equal B.equal) left right )
  ;;

  let tests ~count =
    Arrow.tests ~count
    @ [ arrow_apply_1 count; arrow_apply_2 count; arrow_apply_3 count ]
  ;;
end
OCaml

Innovation. Community. Security.