Module

# Data.Binary.Class

Package
purescript-binary
Repository
Unisay/purescript-binary

### #BitSource

``newtype Bit``

#### Constructors

• `Bit Boolean`

#### Instances

• `Newtype Bit _`
• `Eq Bit`
• `Ord Bit`
• `HeytingAlgebra Bit`
• `BooleanAlgebra Bit`
• `Bounded Bit`
• `Show Bit`
• `Binary Bit`
• `Fixed Bit`
• `FitsInt Bit`

### #charToBitSource

``charToBit :: Char -> Maybe Bit``

### #bitToCharSource

``bitToChar :: Bit -> Char``

### #BitsSource

``newtype Bits``

#### Constructors

• `Bits (Array Bit)`

#### Instances

• `Newtype Bits _`
• `Eq Bits`
• `Show Bits`
• `Semigroup Bits`
• `Ord Bits`
• `Semiring Bits`
• `Ring Bits`
• `Binary Bits`
• `Elastic Bits`

### #lsbSource

``lsb :: Bits -> Bit``

Least significant bit

### #msbSource

``msb :: Bits -> Bit``

most significant bit

### #alignSource

``align :: Bits -> Bits -> Tuple Bits Bits``

align length by adding zeroes from the left

``head :: Bits -> Bit``

### #tailSource

``tail :: Bits -> Bits``

### #initSource

``init :: Bits -> Bits``

### #lastSource

``last :: Bits -> Bit``

### #dropSource

``drop :: Int -> Bits -> Bits``

### #takeSource

``take :: Int -> Bits -> Bits``

### #unconsSource

``uncons :: Bits -> { head :: Bit, tail :: Bits }``

### #lengthSource

``length :: Bits -> Int``

### #BinarySource

``class (Ord a) <= Binary a  where``

#### Members

• `_0 :: a`
• `_1 :: a`
• `and :: a -> a -> a`
• `xor :: a -> a -> a`
• `or :: a -> a -> a`
• `invert :: a -> a`
• `add' :: Bit -> a -> a -> Overflow Bit a`
• `leftShift :: Bit -> a -> Overflow Bit a`
• `rightShift :: Bit -> a -> Overflow Bit a`
• `toBits :: a -> Bits`

#### Instances

• `Binary Int`
• `Binary Bit`
• `Binary Bits`

### #isOddSource

``isOdd :: forall a. Binary a => a -> Boolean``

### #isEvenSource

``isEven :: forall a. Binary a => a -> Boolean``

### #toBinStringSource

``toBinString :: forall a. Binary a => a -> String``

### #tryFromBinStringSource

``tryFromBinString :: forall a. Fixed a => String -> Maybe a``

### #diffBitsSource

``diffBits :: Bits -> Bits -> Bits``

### #FitsIntSource

``class (Binary a) <= FitsInt a  where``

#### Members

• `toInt :: a -> Int`

#### Instances

• `FitsInt Int`
• `FitsInt Bit`

### #FixedSource

``class (Bounded a, Binary a) <= Fixed a  where``

#### Members

• `numBits :: Proxy a -> Int`
• `tryFromBits :: Bits -> Maybe a`

#### Instances

• `Fixed Int`
• `Fixed Bit`

### #tryToIntSource

``tryToInt :: forall a. Binary a => a -> Maybe Int``

### #tryFromIntSource

``tryFromInt :: forall a. Fixed a => Int -> Maybe a``

``modAdd :: forall a. Fixed a => a -> a -> a``

### #modMulSource

``modMul :: forall a. Fixed a => a -> a -> a``

### #diffFixedSource

``diffFixed :: forall a. Fixed a => a -> a -> a``

``add :: forall a. Binary a => a -> a -> Overflow Bit a``

Unsigned binary addition Returns overflow bit

``unsafeAdd :: forall a. Binary a => a -> a -> a``

### #unsafeRightShiftSource

``unsafeRightShift :: forall a. Binary a => a -> a``

### #unsafeLeftShiftSource

``unsafeLeftShift :: forall a. Binary a => a -> a``

### #ElasticSource

``class (Binary a) <= Elastic a  where``

#### Members

• `fromBits :: Bits -> a`
• `extendOverflow :: Overflow Bit a -> a`

#### Instances

• `Elastic Bits`

``addLeadingZeros :: forall a. Elastic a => Int -> a -> a``

``stripLeadingZeros :: forall a. Elastic a => a -> a``

``extendAdd :: forall a. Elastic a => a -> a -> a``

### #tryFromBinStringElasticSource

``tryFromBinStringElastic :: forall a. Elastic a => String -> Maybe a``

### #fromIntSource

``fromInt :: forall a. Elastic a => Int -> a``

### #halfSource

``half :: forall a. Elastic a => a -> a``

### #doubleSource

``double :: forall a. Elastic a => a -> a``

### #diffElasticSource

``diffElastic :: forall a. Elastic a => a -> a -> a``

### #divModSource

``divMod :: forall a. Elastic a => a -> a -> Tuple a a``

### #multiplySource

``multiply :: forall a. Elastic a => a -> a -> a``

``newtype Radix``

The number of unique digits (including zero) used to represent integers in a specific base.

#### Instances

• `Eq Radix`
• `Show Radix`
• `Ord Radix`

### #binSource

``bin :: Radix``

The base-2 system.

### #octSource

``oct :: Radix``

The base-8 system.

### #decSource

``dec :: Radix``

The base-10 system.

### #hexSource

``hex :: Radix``

The base-16 system.

### #toStringAsSource

``toStringAs :: forall a. Binary a => Radix -> a -> String``