(.module: [library [lux #* [abstract ["." monad]] [control ["<>" parser ("#\." monad) ["" code (#+ Parser)] ["" analysis] ["" synthesis]]] [data ["." product] [collection ["." list ("#\." functor)]]] [macro (#+ with_identifiers) ["." code] [syntax (#+ syntax:)]] [tool [compiler ["." phase]]]]]) (type: Declaration {#name Code #label Text #phase Text #archive Text #inputs (List Code)}) (def: (declaration default) (-> Code (Parser Declaration)) (.form ($_ <>.and .any .local_identifier .local_identifier .local_identifier (.tuple (<>.some .any))))) (template [ ] [(syntax: .public ( [[name extension phase archive inputs] (..declaration (` )) body .any]) (let [g!name (code.local_identifier extension) g!phase (code.local_identifier phase) g!archive (code.local_identifier archive)] (with_identifiers [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:] )