Bits

lib/Bits.gob

The bitwise operators, a class each like the arithmetic ones, so that a type can have some of them without the rest: a set has union, intersection and symmetric difference, and nothing to shift.

class BitAnd a
fun and : [BitAnd a] fun(a, a) -> a
class BitOr a
fun or : [BitOr a] fun(a, a) -> a
class BitXor a
fun xor : [BitXor a] fun(a, a) -> a
class Shift a
fun shl : [Shift a] fun(a, Int) -> a
fun shr : [Shift a] fun(a, Int) -> a
infix BitShift (<<) = Shift.shl -- left-associative
infix BitShift (>>) = Shift.shr -- left-associative
infix BitAnd (&) = BitAnd.and -- left-associative
infix BitOr (|) = BitOr.or -- left-associative
infix BitXor (^) = BitXor.xor -- left-associative
instance BitAnd Int
instance BitOr Int
instance BitXor Int
instance Shift Int
instance BitAnd Byte
instance BitOr Byte
instance BitXor Byte
instance Shift Byte