(.module: [lux #* ["_" test (#+ Test)] [abstract [monad (#+ do)]] [math ["." random (#+ Random)]]] {1 ["." / [// [equivalence (#+ Equivalence)]]]}) (def: #export (spec (^open "@//.") (^open "@//.") gen-sample) (All [a] (-> (Equivalence a) (/.Monoid a) (Random a) Test)) (do random.monad [sample gen-sample left gen-sample mid gen-sample right gen-sample] (<| (_.with-cover [/.Monoid]) ($_ _.and (_.test "Left identity." (@//= sample (@//compose @//identity sample))) (_.test "Right identity." (@//= sample (@//compose sample @//identity))) (_.test "Associativity." (@//= (@//compose left (@//compose mid right)) (@//compose (@//compose left mid) right))) ))))