aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/test/lux/meta/type/poly.lux
blob: e2aa7d03ebaed7ab9c25383e699e9aa910454d56 (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
46
47
48
(.require
 [library
  [lux (.except)
   [abstract
    [monad (.only do)]]
   [control
    ["?" parser]]
   [data
    ["[0]" bit (.use "[1]#[0]" equivalence)]]
   [math
    ["[0]" random]
    [number
     ["[0]" nat (.use "[1]#[0]" equivalence)]]]
   [meta
    ["[0]" static]
    ["[0]" type
     ["?[1]" \\parser]]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(with_expansions [<bit> (static.random_bit)
                  <nat> (static.random_nat)]
  (def constant
    (/.polytypic constant
      (`` (all ?.either
               (,, (with_template [<type> <constant>]
                     [(do ?.monad
                        [_ (?type.sub <type>)]
                        (in (` (is <type>
                                   <constant>))))]

                     [Bit <bit>]
                     [Nat <nat>]))
               ))))

  (def .public test
    Test
    (<| (_.covering /._)
        (do [! random.monad]
          [])
        (all _.and
             (_.coverage [/.polytypic]
               (and (bit#= <bit> (constant Bit))
                    (nat#= <nat> (constant Nat))))
             )))
  )