aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/abstract/comonad.lux
blob: 701ec93dbe3198bf0814ebd7005bf33d80bef9f5 (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
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [data
    ["[0]" identity (.only Identity)]]
   [math
    ["[0]" random]
    [number
     ["n" nat]]]
   ["_" test (.only Test)]]]
 [\\library
  ["[0]" /]])

(def .public test
  Test
  (do random.monad
    [sample random.nat]
    (<| (_.covering /._)
        (all _.and
             (_.coverage [/.be]
               (n.= (++ sample)
                    (is (Identity Nat)
                        (/.be identity.comonad
                          [value (out sample)]
                          (out (++ value))))))
             ))))