[{"name":"Bit","comment":" A primitive: the single bit\n\n@docs Bit, opposite\n\nI'll happily add or merge more stuff!\nJust open an issue or a PR\n\n","unions":[{"name":"Bit","comment":" One of 2 states:\n\n  - 1, on: `I`\n  - 0, off: `O`\n\nThis right here is really the core of this library.\nRepresenting bits safely is now quite readable!\n\n    [ O, I, I, I, O, O, I, O ]\n    --: List Bit\n\n    randomBit : Random.Generator Bit\n    randomBit =\n        Random.uniform I [ O ]\n\n    fuzz : Fuzz.Fuzzer Bit\n    fuzz =\n        Fuzz.oneOfValues [ O, I ]\n\nfor an example of using this to represent an `Id`,\nvisit the [readme](https://dark.elm.dmy.fr/packages/lue-bird/elm-bits/latest/)\n\n","args":[],"cases":[["I",[]],["O",[]]]}],"aliases":[],"values":[{"name":"opposite","comment":" Switch `O` ↔ `I`. Often called the not, negate or flip operator\n","type":"Bit.Bit -> Bit.Bit"}],"binops":[]},{"name":"Bits","comment":" Convert from and to a `List` of [`Bit`](Bit#Bit)s\n\n@docs fromIntUnsigned, fromIntSigned, fromBytes\n\nIf you have a need for UTF-8 characters and Floats, feel free to [open an issue](https://github.com/lue-bird/elm-bits/issues/new) or PR.\n\n\n## transform\n\n@docs toIntUnsigned, toIntSigned, toIntUnsigned8s, toIntUnsigned16s, toIntUnsigned32s\n\nYou can also use all the operations that work on `List`, for example\n\n    -- complement\n    List.map Bit.opposite\n\n    -- left shift\n    (_ ++ List.repeat n Bit.O) |> List.take x\n\n    -- left right\n    (List.repeat n Bit.O ++ _) |> List.take x\n\n    ...\n\n","unions":[],"aliases":[],"values":[{"name":"fromBytes","comment":" Convert from [`Bytes`](https://dark.elm.dmy.fr/packages/elm/bytes/latest/)\nto a list of individual bits.\n","type":"Bytes.Bytes -> List.List Bit.Bit"},{"name":"fromIntSigned","comment":" Encode a signed `Int` with a given bit size `n`\nranging from `-(2 ^ (n - 1))` to `2 ^ (n - 1) - 1`.\nFor example, bit size 5 ranges from -16 to 15\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    -6 |> Bits.fromIntSigned 5\n    --> [ I, I, O, I, O ]\n\n    10 |> Bits.fromIntSigned 6\n    --> [ O, O, I, O, I, O ]\n\n","type":"Basics.Int -> Basics.Int -> List.List Bit.Bit"},{"name":"fromIntUnsigned","comment":" Convert the unsigned `Int`\nto a given number of bits.\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    14 |> Bits.fromIntUnsigned 4\n    --> [ I, I, I, O ]\n\n","type":"Basics.Int -> Basics.Int -> List.List Bit.Bit"},{"name":"toIntSigned","comment":" Create signed `Int` from a bit array's in 2's complement encoding\nusing its length as the `Int`'s bit count.\n\nSo given bit count `n`,\ndecodes in the range `-(2 ^ (n - 1))` → `2 ^ (n - 1) - 1`.\nFor example, bit size 5 ranges from -16 to 15\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    [ O, I, O, I, O ] |> Bits.toIntSigned\n    --> 10\n\n    [ I, O, I, O, I, O, I, O ] |> Bits.toIntSigned\n    --> -86\n\n    [ O, O, O, O, O, I, O, I, O, I, O ]\n        |> Bits.toIntSigned\n    --> 42\n\n","type":"List.List Bit.Bit -> Basics.Int"},{"name":"toIntUnsigned","comment":" Convert ≤ 32 bits into a natural `Int` ≥ 0\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    [ I, O, O, I, O, I ]\n        |> Bits.toIntUnsigned\n    --> 37\n\n","type":"List.List Bit.Bit -> Basics.Int"},{"name":"toIntUnsigned16s","comment":" Convert to a list of `Int`s in range 0..65535\nfrom a list of individual bits.\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    [ O, O, O, O, O, O, O, O, O, O, I, O, O, I, O, I, {- 16 bits -} O, O, O, O, O, O, O, O, O, O, I, O, O, I, I, I ]\n        |> Bits.toIntUnsigned16s\n    --> [ 37, 39 ]\n\nFrom there it's easy to convert to e.g. [`Bytes`](https://dark.elm.dmy.fr/packages/elm/bytes/latest/)\nusing `List.map Bytes.Encode.unsignedInt16 |> Bytes.Encode.sequence`\n\nYou should make sure in your code that, the given bits are a multiple of 16.\nIf there are remaining bits, `toIntUnsigned16s` treats your input as if it had enough 0s padded to the right.\n\n","type":"List.List Bit.Bit -> List.List Basics.Int"},{"name":"toIntUnsigned32s","comment":" Convert to a list of `Int`s in range 0..4294967295\nfrom a list of individual bits.\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    [ O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, I, O, O, I, O, I, {- 32 bits -} O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, O, I, O, O, I, I, I ]\n        |> Bits.toIntUnsigned32s\n    --> [ 37, 39 ]\n\nFrom there it's easy to convert to e.g. [`Bytes`](https://dark.elm.dmy.fr/packages/elm/bytes/latest/)\nusing `List.map Bytes.Encode.unsignedInt32 |> Bytes.Encode.sequence`\n\nYou should make sure in your code that, the given bits are a multiple of 32.\nIf there are remaining bits, `toIntUnsigned32s` treats your input as if it had enough 0s padded to the right.\n\n","type":"List.List Bit.Bit -> List.List Basics.Int"},{"name":"toIntUnsigned8s","comment":" Convert to a list of `Int`s in range 0..255\nfrom a list of individual bits.\n\n    import Bit exposing (Bit(..))\n    import Bits\n\n    [ O, O, I, O, O, I, O, I, {- 8 bits -} O, O, I, O, O, I, I, I ]\n        |> Bits.toIntUnsigned8s\n    --> [ 37, 39 ]\n\nFrom there it's easy to convert to e.g. [`Bytes`](https://dark.elm.dmy.fr/packages/elm/bytes/latest/)\nusing `List.map Bytes.Encode.unsignedInt8 |> Bytes.Encode.sequence`\n\nYou should make sure in your code that, the given bits are a multiple of 8.\nIf there are remaining bits, `toIntUnsigned8s` treats your input as if it had enough 0s padded to the right.\n\n","type":"List.List Bit.Bit -> List.List Basics.Int"}],"binops":[]}]