package preface

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

Source file functor.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
open QCheck2

module Suite
    (R : Model.COVARIANT_1)
    (F : Preface_specs.FUNCTOR with type 'a t = 'a R.t)
    (A : Model.T0)
    (B : Model.T0)
    (C : Model.T0) =
struct
  module Laws = Preface_laws.Functor.For (F)

  let print pp = Format.asprintf "%a" (R.pp pp)

  let functor_1 count =
    let generator = R.generator A.generator in
    let print = print A.pp in
    Util.test ~count ~print generator Laws.functor_1 (fun lhs rhs x ->
        let left = lhs x
        and right = rhs x in
        R.equal A.equal left right )
  ;;

  let functor_2 count =
    let generator =
      let f = fun1 A.observable B.generator
      and g = fun1 C.observable A.generator in
      Gen.tup3 f g (R.generator C.generator)
    in
    let print (_, _, x) = print C.pp x in
    Util.test ~count ~print generator Laws.functor_2 (fun lhs rhs (ff, gg, x) ->
        let f = Fn.apply ff
        and g = Fn.apply gg in
        let left = lhs f g x
        and right = rhs f g x in
        R.equal B.equal left right )
  ;;

  let tests ~count = [ functor_1 count; functor_2 count ]
end
OCaml

Innovation. Community. Security.