(.require [library [lux (.except Type static public private) [abstract [equivalence (.only Equivalence)] ["[0]" monad (.only do)]] [data ["[0]" product] ["[0]" binary ["[1]F" \\format (.only Format) (.use "[1]#[0]" monoid)]] [collection ["[0]" sequence (.only Sequence)]]]]] ["[0]" // ["[0]" modifier (.only Modifier modifiers)] ["[1][0]" constant (.only UTF8) ["[1]/[0]" pool (.only Pool Resource)]] ["[1][0]" index (.only Index)] ["[1][0]" attribute (.only Attribute)] ["[1][0]" type (.only Type) [category (.only Value)] [descriptor (.only Descriptor)]]]) (type .public Field (Rec Field (Record [#modifier (Modifier Field) #name (Index UTF8) #descriptor (Index (Descriptor Value)) #attributes (Sequence Attribute)]))) (modifiers Field ["0001" public] ["0002" private] ["0004" protected] ["0008" static] ["0010" final] ["0040" volatile] ["0080" transient] ["1000" synthetic] ["4000" enum] ) (def .public equivalence (Equivalence Field) (all product.equivalence modifier.equivalence //index.equivalence //index.equivalence (sequence.equivalence //attribute.equivalence))) (def .public (format field) (Format Field) (`` (all binaryF#composite (~~ (with_template [ ] [( (the field))] [modifier.format #modifier] [//index.format #name] [//index.format #descriptor] [(binaryF.sequence_16 //attribute.format) #attributes])) ))) (def .public (field modifier name with_signature? type attributes) (-> (Modifier Field) UTF8 Bit (Type Value) (Sequence Attribute) (Resource Field)) (do [! //constant/pool.monad] [@name (//constant/pool.utf8 name) @descriptor (//constant/pool.descriptor (//type.descriptor type)) @signature (if with_signature? (at ! each (|>> {.#Some}) (//attribute.signature (//type.signature type))) (in {.#None}))] (in [#modifier modifier #name @name #descriptor @descriptor #attributes (case @signature {.#Some @signature} (sequence.suffix @signature attributes) {.#None} attributes)])))