aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/abstract/comonad.lux
blob: 9b4d935d8644d94a5c05d4681561db0d87e476e5 (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
(.module:
  [library
   [lux #*
    [abstract
     [monad (#+ do)]]
    [data
     ["." identity (#+ Identity)]]
    [math
     ["." random]
     [number
      ["n" nat]]]
    ["_" test (#+ Test)]]]
  [\\library
   ["." /]])

(def: #export test
  Test
  (do random.monad
    [sample random.nat]
    (<| (_.covering /._)
        ($_ _.and
            (_.cover [/.be]
                     (n.= (inc sample)
                          (: (Identity Nat)
                             (/.be identity.comonad
                               [value (unwrap sample)]
                               (unwrap (inc value))))))
            ))))