(.module: [lux (#- nat int rev) [abstract ["." monad (#+ do)]] [data ["." maybe] ["." name ("#\." equivalence)]]]) (type: #export Annotation Code) (def: #export (value tag ann) (-> Name Annotation (Maybe Code)) (case ann [_ (#.Record ann)] (loop [ann ann] (case ann (#.Cons [key value] ann') (case key [_ (#.Tag tag')] (if (name\= tag tag') (#.Some value) (recur ann')) _ (recur ann')) #.Nil #.None)) _ #.None)) (template [ ] [(def: #export ( tag ann) (-> Name Annotation (Maybe )) (case (..value tag ann) (#.Some [_ ( value)]) (#.Some value) _ #.None))] [bit #.Bit Bit] [nat #.Nat Nat] [int #.Int Int] [rev #.Rev Rev] [frac #.Frac Frac] [text #.Text Text] [identifier #.Identifier Name] [tag #.Tag Name] [form #.Form (List Code)] [tuple #.Tuple (List Code)] [record #.Record (List [Code Code])] ) (def: #export documentation (-> Annotation (Maybe Text)) (..text (name-of #.doc))) (def: #export (flagged? flag) (-> Name Annotation Bit) (|>> (..bit flag) (maybe.default false))) (template [ ] [(def: #export (-> Annotation Bit) (..flagged? (name-of )))] [structure? #.struct?] [recursive-type? #.type-rec?] [signature? #.sig?] ) (def: (parse-text input) (-> Code (Maybe Text)) (case input [_ (#.Text actual-value)] (#.Some actual-value) _ #.None)) (template [ ] [(def: #export ( ann) (-> Annotation (List Text)) (maybe.default (list) (do {! maybe.monad} [args (..tuple (name-of ) ann)] (monad.map ! ..parse-text args))))] [function-arguments #.func-args] [type-arguments #.type-args] )