aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/data/identity.lux
blob: 3d0ae44c2cd845a3f4384d0f00c2e95fabab1c4b (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
34
35
36
37
38
39
40
41
42
43
44
45
(.module:
  [lux #*
   ["_" test (#+ Test)]
   [abstract
    [equivalence (#+)]
    [functor (#+)]
    comonad
    [monad (#+ do)]
    {[0 #test]
     [/
      ["$." functor (#+ Injection Comparison)]
      ["$." apply]
      ["$." monad]]}]
   [data
    ["." text ("#@." monoid equivalence)
     format]]]
  {1
   ["." / (#+ Identity)]})

(def: injection
  (Injection Identity)
  (|>>))

(def: comparison
  (Comparison Identity)
  (function (_ ==)
    ==))

(def: #export test
  Test
  (<| (_.context (%name (name-of /.Identity)))
      ($_ _.and
          ($functor.spec ..injection ..comparison /.functor)
          ($apply.spec ..injection ..comparison /.apply)
          ($monad.spec ..injection ..comparison /.monad)
          
          (let [(^open "/@.") /.comonad]
            (_.test "CoMonad does not affect values."
                    (and (text@= "yololol" (/@unwrap "yololol"))
                         (text@= "yololol" (be /.comonad
                                             [f text@compose
                                              a "yolo"
                                              b "lol"]
                                             (f a b))))))
          )))