aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/abstract/monoid.lux
blob: 75eee67c6ae6ba3090540b43984bf7ec096ae1e1 (plain)
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
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]]
    [math
     ["." random (#+ Random)]
     [number
      ["." nat]
      ["." int]]]]]
  [\\library
   ["." /
    [//
     [equivalence (#+ Equivalence)]]]])

(def: .public test
  Test
  (do random.monad
    [natL random.nat
     natR random.nat
     intL random.int
     intR random.int]
    (<| (_.covering /._)
        ($_ _.and
            (_.cover [/.composite]
                     (let [[natLR intLR] (\ (/.composite nat.addition int.multiplication) compose
                                            [natL intL] [natR intR])]
                       (and (nat.= (\ nat.addition compose natL natR)
                                   natLR)
                            (int.= (\ int.multiplication compose intL intR)
                                   intLR))))
            ))))