(.module: [lux #* [control [monoid (#+ Monoid)] [equivalence (#+ Equivalence)] hash [codec (#+ Codec)]] function]) (structure: #export equivalence (Equivalence Bit) (def: (= x y) (if x y (not y)))) (structure: #export hash (Hash Bit) (def: &equivalence ..equivalence) (def: (hash value) (case value #1 1 #0 0))) (template [ ] [(structure: #export (Monoid Bit) (def: identity ) (def: (compose x y) ( x y)))] [disjunction #0 or] [conjunction #1 and] ) (structure: #export codec (Codec Text Bit) (def: (encode x) (if x "#1" "#0")) (def: (decode input) (case input "#1" (#.Right #1) "#0" (#.Right #0) _ (#.Left "Wrong syntax for Bit.")))) (def: #export complement {#.doc (doc "Generates the complement of a predicate." "That is a predicate that returns the oposite of the original predicate.")} (All [a] (-> (-> a Bit) (-> a Bit))) (compose not))