lue-bird / elm-bits / Bit

A primitive: the single bit


type Bit
    = I
    | O

One of 2 states:

This right here is really the core of this library. Representing bits safely is now quite readable!

ArraySized.l8 O I I I O O I O
--: ArraySized Bit (In (Up8 minX_) (Up8 maxX_))

for an example of using this to represent an Id, visit the readme

create

random : Random.Generator Bit

Uniform Random.Generator for either I or O

fuzz : Fuzzer Bit

Uniform Fuzzer for either I or O

N

fromN : N (N.In min_ (N.Up maxTo1_ N.To N1)) -> Bit

n0O, n1I

toN : Bit -> N (N.In (N.Up0 minX_) (N.Up1 maxX_))

Convert O to n0, I to 1. N (In (Up0 minX_) (Up1 maxX_)) means that the result will be between 0 & 1

toInt =
    Bit.toN >> N.toInt

alter

opposite : Bit -> Bit

Switch OI. Often called the NOT operator