aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/specification/lux/abstract/interval.lux
blob: c5d89aab391a3ded466a3680215ff9eedd721de8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
(.module:
  [library
   [lux #*
    ["_" test (#+ Test)]
    [abstract
     [monad (#+ do)]
     ["." order]]
    [math
     ["." random (#+ Random)]]]]
  [\\library
   ["." /]])

(def: #export (spec (^open "@//.") gen_sample)
  (All [a] (-> (/.Interval a) (Random a) Test))
  (<| (_.for [/.Interval])
      (do random.monad
        [sample gen_sample]
        ($_ _.and
            (_.test "No value is bigger than the top."
                    (@//< @//top sample))
            (_.test "No value is smaller than the bottom."
                    (order.> @//&order @//bottom sample))
            ))))