aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/type/variance.lux
blob: e683b1f64b6fcf932674f97f802a08125e81579c (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
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]]
    [math
     ["." random (#+ Random)]]]]
  [\\library
   ["." /
    ["/#" // #_
     ["#." check]]]])

(type: Super
  (Ex [sub] [Text sub]))

(type: Sub
  (Super Bit))

(def: .public test
  Test
  (<| (_.covering /._)
      ($_ _.and
          (_.cover [/.Co]
                   (and (//check.checks? (type (/.Co Super)) (type (/.Co Sub)))
                        (not (//check.checks? (type (/.Co Sub)) (type (/.Co Super))))))
          (_.cover [/.Contra]
                   (and (//check.checks? (type (/.Contra Sub)) (type (/.Contra Super)))
                        (not (//check.checks? (type (/.Contra Super)) (type (/.Contra Sub))))))
          (_.cover [/.In]
                   (and (//check.checks? (type (/.In Super)) (type (/.In Super)))
                        (//check.checks? (type (/.In Sub)) (type (/.In Sub)))
                        (not (//check.checks? (type (/.In Sub)) (type (/.In Super))))
                        (not (//check.checks? (type (/.In Super)) (type (/.In Sub))))))
          )))