
Here's an example (not a complete module) I was using to represent bit-oriented structures as they occur in certain space applications, notably GPS frames. "Fixed" allows for fixed-sized fields and lets the end user choose the integral type that's best for the structure. At least it's not a parser or language example. :-) -scooter -- | Member fields, etc., that comprise a 'BitStruct' data Member where Field :: String -- Field name -> Int -- Field length -> Bool -- Signed (True) or unsigned (False) -> Member ZeroPad :: String -- Field name -> Int -- Field length -> Member OnesPad :: String -- Field name -> Int -- Field length -> Member ArbPad :: String -- Field name -> Int -- Field length -> Member Reserved :: String -- Field name -> Int -- Field length -> Member Fixed :: (Integral x, Show x) => String -- Field name -> Int -- Field length -> Bool -- Signed (True) or unsigned (False) -> x -- Type of the fixed field's value -> Member Variant :: (Integral x, Show x) => String -- Variant prefix name -> Maybe BitStruct -- Header before the tag -> TagElement -- The tag element itself -> Maybe BitStruct -- Common elements after the tag -> Seq (x, BitStruct) -- Variant element tuples (value, structure) -> Member -- Mult-value variant: Use this when multiple variant tag values have the -- same structure: MultiValueVariant :: (Integral x, Show x) => String -- Variant prefix name -> Maybe BitStruct -- Header before the tag -> TagElement -- The tag element itself -> Maybe BitStruct -- Common elements after the tag -> Seq ([x], BitStruct) -- Variant element tuples ([values], structure) -> Member