lue-bird/elm-bits/2.0.6

NOTE: the latest version is 10.1.1

Lue.Bits

Working with an Arr of Bits.

create

random : Nat (ArgIn min max maybeN) -> Generator (Arr (In min max) Bit)

A Random.Generator for an Arr of Bits.

To use it effectively, you will need some extra bits of randomness.

transform

toNat : Arr (In min Nat53) Bit -> Nat (Min Nat0)

Convert an Arr of up to 53 Bits to a Nat.

Bits from the 53th index become mathematically unsound so they are avoided.

Bits.toNat (Arr.from8 I O O O I O I O)
--> Nat 138
Arr (In min max) Bit
-> Arr (Min Nat0) (Arr (In Nat8 (Nat8Plus a)) Bit)

Group an Arr of Bits into Arrs of size 8.

Bits.toBytes (Arr.from1 O)
--> Arr.from1 (Arr.from8 O O O O O O O O)


Arr.from3 I I I
    |> Arr.extendOnly nat8 (Arr.from8 O I I I O I O O)
    |> Arr.extendOnly nat8 (Arr.from8 O I I I O I O O)
    |> Arr.extendOnly nat8 (Arr.from8 O I I I O I O O)
    |> Bits.toBytes
--> (Arr.from8 O O O O O I I I
-->     |> Arr.push (Arr.from8 O I I I O I O O)
-->     |> Arr.push (Arr.from8 O I I I O I O O)
-->     |> Arr.push (Arr.from8 O I I I O I O O)
--> )

Os at the start are kept.

padToByte : Arr (In min Nat8) Bit -> Arr (In Nat8 (Nat8Plus a)) Bit

Fill Os to the begin of the Arr until it has 8 elements.

Arr.from3 I I I |> Bits.toBytes
--> Arr.from8 O O O O O I I I

extra

serialize : Nat (ArgIn min max maybeN) -> Codec String (Arr (In min max) Bit)

A Codec for an Arr of Bits.

 

Lue. is just the github username to avoid overlaps in module names.