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

(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))))))
            ))))