lue-bird/elm-bits/7.0.1

NOTE: the latest version is 10.1.1

Bit

A primitive: the single bit

type Bit
= I
| O

One of 2 states:

  • 1, on: I
  • 0, off: O

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 : Generator Bit

Uniform Random.Generator for either I or O

fuzz : Fuzzer Bit

Uniform Fuzzer for either I or O

N

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

n0 → O, n1 → I

toN : Bit -> N (In (Up0 minX_) (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

Switch O ↔ I. Often called the NOT operator

I'll be happy to add or merge more stuff! Just open an issue or a PR