(.require [library [lux (.except) [abstract [monoid (.only Monoid)] [equivalence (.only Equivalence)] [hash (.only Hash)] [codec (.only Codec)]] [control ["[0]" function]]]]) (with_template [ ] [(def .public Bit #0) (def .public Bit #1)] [no yes] [off on] ) (def .public equivalence (Equivalence Bit) (implementation (def (= x y) (if x y (not y))))) (def .public hash (Hash Bit) (implementation (def equivalence ..equivalence) (def (hash value) (case value #0 2 #1 3)))) (with_template [ ] [(def .public (Monoid Bit) (implementation (def identity ) (def (composite x y) ( x y))))] [disjunction #0 or] [conjunction #1 and] ) (def .public codec (Codec Text Bit) (implementation (def (encoded x) (if x "#1" "#0")) (def (decoded input) (case input "#1" {.#Right #1} "#0" {.#Right #0} _ {.#Left "Wrong syntax for Bit."})))) (def .public complement (All (_ a) (-> (-> a Bit) (-> a Bit))) (function.composite not))