(.using
  [library
   [lux {"-" or and not}
    ["$" documentation {"+" documentation:}]
    [data
     ["[0]" text {"+" \n}
      ["%" format {"+" format}]]]
    [macro
     ["[0]" template]]]]
  [\\library
   ["[0]" /]])

(template [<name> <doc>]
  [(documentation: <name>
     <doc>)]

  [/.or "Bitwise or."]
  [/.xor "Bitwise xor."]
  [/.and "Bitwise and."]
  
  [/.left_shifted "Bitwise left-shift."]
  [/.right_shifted "Unsigned/logic bitwise right-shift."]
  )

(documentation: /.Mask
  "A pattern of bits that can be imposed on I64 values.")

(documentation: /.bit
  "A mask with only a specific bit set."
  [(bit position)])

(documentation: /.sign
  "A mask for the sign bit of ints.")

(documentation: /.not
  "Bitwise negation.")

(documentation: /.mask
  "Mask a block of bits of the specified size."
  [(mask amount_of_bits)])

(documentation: /.ones
  "Count the number of 1s in a bit-map."
  [(ones it)])

(template [<name> <doc>]
  [(documentation: <name>
     <doc>)]

  [/.zero "Clear bit at the given index."]
  [/.one "Set bit at given index."]
  [/.flipped "Flip bit at given index."]
  )

(documentation: /.one?
  ""
  [(one? index input)])

(documentation: /.zero?
  ""
  [(zero? index input)])

(documentation: /.region
  "A mask for a block of bits of the given size, starting at the given offset."
  [(region offset size)])

(documentation: (/.Sub width)
  "A sub-space of I64 with a reduce amount of bits.")

(documentation: /.sub
  "Given a width in the interval (0,64), yields an implementation for integers of that width."
  [(sub width)])

(.def: .public documentation
  (.List $.Module)
  ($.module /._
            ""
            [..or
             ..xor
             ..and
             ..left_shifted
             ..right_shifted
             ..Mask
             ..bit
             ..sign
             ..not
             ..mask
             ..ones
             ..zero
             ..one
             ..flipped
             ..one?
             ..zero?
             ..region
             ..Sub
             ..sub
             ($.default /.bits_per_byte)
             ($.default /.bytes_per_i64)
             ($.default /.width)
             ($.default /.false)
             ($.default /.true)
             ($.default /.equivalence)
             ($.default /.hash)
             ($.default /.disjunction)
             ($.default /.conjunction)
             ($.default /.reversed)
             ($.default /.left_rotated)
             ($.default /.right_rotated)]
            []))
