... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.

(.using
 [library
  [lux (.except)
   [abstract
    ["[0]" monad]]
   [data
    [collection
     ["[0]" list]
     ["[0]" set]]]
   [math
    ["[0]" random (.only Random) (.use "[1]#[0]" functor)]
    [number
     [/64
      ["[0]" natural]]]]
   [macro
    ["[0]" expansion]]
   [test
    ["_" property (.only Test)]]]]
 [\\library
  ["[0]" /]])

(the .public random
  (Random /.Channel)
  (random#each (natural.% (++ /.maximum))
               random.natural))

(the .public test
  Test
  (<| (_.covering /._)
      (monad.let [! random.monad]
        [example ..random])
      (_.for [/.Channel])
      (all _.and
           (expansion.let [<options> (these /.minimum
                                            /.maximum

                                            /.percussion)]
             (_.coverage [<options>]
               (let [options (is (List /.Channel)
                                 (list <options>))
                     uniques (set.of_list natural.hash options)]
                 (natural.= (list.size options)
                            (set.size uniques)))))
           (_.coverage [/.tonal?]
             (or (/.tonal? example)
                 (natural.= /.percussion example)))
           )))
