(.require [library [lux (.except local) [abstract [equivalence (.only Equivalence)] [hash (.only Hash)]] [control ["[0]" pipe]] [data [text ["%" \\format (.only Format)]]] [math [number ["n" nat]]] [meta ["[0]" symbol] [macro ["^" pattern]]]]] ["[0]" / ["[1][0]" variable (.only Variable)]]) (type .public Constant Symbol) (type .public Reference (Variant {#Variable Variable} {#Constant Constant})) (def .public equivalence (Equivalence Reference) (implementation (def (= reference sample) (when [reference sample] (^.with_template [ ] [[{ reference} { sample}] (at = reference sample)]) ([#Variable /variable.equivalence] [#Constant symbol.equivalence]) _ false)))) (def .public hash (Hash Reference) (implementation (def equivalence ..equivalence) (def (hash value) (when value (^.with_template [ ] [{ value} (|> value (at hash) (n.* ))]) ([2 #Variable /variable.hash] [3 #Constant symbol.hash]) )))) (with_template [ ] [(def .public (template ( content) [(<| {} {} content)]))] [local ..#Variable /variable.#Local] [foreign ..#Variable /variable.#Foreign] ) (with_template [ ] [(def .public (template ( content) [(<| {} content)]))] [variable ..#Variable] [constant ..#Constant] ) (`` (def .public self (template (self) [(..variable (,, (/variable.self)))]))) (def .public format (Format Reference) (|>> (pipe.when {#Variable variable} (/variable.format variable) {#Constant constant} (%.symbol constant))))