(.using [library [lux "*" [abstract ["[0]" monad]] [control ["<>" parser ("[1]#[0]" monad) ["" code {"+" Parser}] ["" analysis] ["" synthesis]]] [data ["[0]" product] [collection ["[0]" list ("[1]#[0]" functor)]]] [macro {"+" with_symbols} ["[0]" code] [syntax {"+" syntax:}]] [tool [compiler ["[0]" phase]]]]]) (type: Declaration (Record [#name Code #label Text #phase Text #archive Text #inputs (List Code)])) (def: (declaration default) (-> Code (Parser Declaration)) (.form ($_ <>.and .any .local_symbol .local_symbol .local_symbol (.tuple (<>.some .any))))) (template [ ] [(syntax: .public ( [[name extension phase archive inputs] (..declaration (` )) body .any]) (let [g!name (code.local_symbol extension) g!phase (code.local_symbol phase) g!archive (code.local_symbol archive)] (with_symbols [g!handler g!inputs g!error g!_] (in (list (` ( (~ name) (.function ((~ g!handler) (~ g!name) (~ g!phase) (~ g!archive) (~ g!inputs)) (.case ((~! ) ((~! monad.do) (~! <>.monad) [(~+ inputs) (~ g!_) ] (.# (~! <>.monad) (~' in) (~ body))) (~ g!inputs)) {.#Right (~ g!_)} (~ g!_) {.#Left (~ g!error)} ((~! phase.failure) (~ g!error))) ))))))))] [.any .end! .and .result "lux def analysis" analysis:] [.any .end! .and .result "lux def synthesis" synthesis:] [.any .end! .and .result "lux def generation" generation:] [.any .end! .and .result "lux def directive" directive:] )