[{"name":"Bit","comment":" A primitive: the single bit\n\n@docs Bit\n\n\n## create\n\n@docs random, fuzz\n\n\n## `N`\n\n@docs fromN, toN\n\n\n## alter\n\n@docs opposite\n\nI'll be happy to 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    ArraySized.l8 O I I I O O I O\n    --: ArraySized Bit (In (Up8 minX_) (Up8 maxX_))\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":"fromN","comment":" `n0` → [`O`](#Bit), `n1` → [`I`](#Bit)\n","type":"N.N (N.In min_ (N.Up maxTo1_ N.To N.N1)) -> Bit.Bit"},{"name":"fuzz","comment":" Uniform `Fuzzer` for either [`I`](#Bit) or [`O`](#Bit)\n","type":"Fuzz.Fuzzer Bit.Bit"},{"name":"opposite","comment":" Switch `O` ↔ `I`. Often called the NOT operator\n","type":"Bit.Bit -> Bit.Bit"},{"name":"random","comment":" Uniform `Random.Generator` for either [`I`](#Bit) or [`O`](#Bit)\n","type":"Random.Generator Bit.Bit"},{"name":"toN","comment":" Convert `O` to `n0`, `I` to `1`.\n`N (In (Up0 minX_) (Up1 maxX_))` means that the result will be between 0 & 1\n\n    toInt =\n        Bit.toN >> N.toInt\n\n","type":"Bit.Bit -> N.N (N.In (N.Up0 minX_) (N.Up1 maxX_))"}],"binops":[]},{"name":"Bits","comment":" [`ArraySized`](https://package.elm-lang.org/packages/lue-bird/elm-typesafe-array/latest/)\nof [`Bit`](Bit#Bit)s\n\nUse what's available in `ArraySized` to create and analyze bits!\n\nUse the helpers here in `Bits`\nwhen you know the exact number of bits, like in an id\n\n\n## `N`\n\n@docs fromN, toN\n\n\n## `Int`\n\n@docs fromIntSigned, toIntSigned\n\n\n## alter\n\n@docs padToAtLeast, takeAtMost, unpad\n@docs toChunksOf\n\nYou can additionally use the operations of `ArraySized`, for example\n\n    -- left shift\n    ArraySized.attach Up (ArraySized.repeat O n...)\n\n    -- complement\n    ArraySized.map Bit.opposite\n\n    ...\n\n","unions":[],"aliases":[],"values":[{"name":"fromIntSigned","comment":" Clamp a signed `Int`, decoding 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 ArraySized\n    import Bit exposing (Bit(..))\n    import N exposing (n5, n6)\n\n    -6 |> Bits.fromIntSigned n5 |> ArraySized.toList\n    --> [ O, I, O, I, O ]\n\n    10 |> Bits.fromIntSigned n6 |> ArraySized.toList\n    --> [ I, O, I, O, I, O ]\n\n","type":"N.N (N.Exactly (N.On bitSize)) -> Basics.Int -> ArraySized.ArraySized Bit.Bit (N.Exactly (N.On bitSize))"},{"name":"fromN","comment":" Convert the unsigned integer to 32 bits\n\nCombine with [`takeAtMost`](#takeAtMost) to clamp to a lower bit size\n\n    import N exposing (n4, n14)\n    import Bit exposing (Bit(..))\n    import ArraySized\n\n    n14 |> Bits.fromN |> Bits.takeAtMost n4 |> ArraySized.toList\n    --> [ I, I, I, O ]\n\nThe `N` is always clamped to `<=  2 ^ 32 - 1`\n\n    import N exposing (n0)\n\n    2 ^ 53 - 1\n        |> N.intToAtLeast n0\n        |> Bits.fromN\n        |> Bits.toN\n        |> N.toInt\n    --> 2 ^ 32 - 1\n\n","type":"N.N range_ -> ArraySized.ArraySized Bit.Bit (N.In (N.Local.Up32 minX_) (N.Local.Up32 maxX_))"},{"name":"padToAtLeast","comment":" Increase the capacity to a given length\nby padding with [`O`](Bit#Bit)s to the beginning\n\nShort for\n\n    ArraySized.padToAtLeast Down lengthMinimum (ArraySized.repeat O)\n\n","type":"N.N (N.In (N.On paddedMin) (N.Up maxX N.To paddedMaxPlusX)) -> ArraySized.ArraySized Bit.Bit (N.In (N.Up paddingMaxPlusX_ N.To paddedMaxPlusX) (N.Up paddingMin_ N.To paddedMin)) -> ArraySized.ArraySized Bit.Bit (N.In (N.On paddedMin) (N.Up maxX N.To paddedMaxPlusX))"},{"name":"takeAtMost","comment":" If the `ArraySized` has a [`I`](Bit#Bit) earlier than a given number of [`Bit`](Bit#Bit)s up,\nreturns only [`I`](Bit#Bit)s up to the given length\n\n    import N exposing (n0, n16)\n    import ArraySized\n\n    2 ^ 25\n        |> N.intToAtLeast n0\n        |> Bits.fromN\n        |> Bits.takeAtMost n16\n        |> ArraySized.maxTo n16\n        |> Bits.toN\n        |> N.toInt\n    --> 2 ^ 16 - 1\n\nIts length after that will be `Exactly` the given desired length.\nSome operations like attaching or `Bits.toN` will stop working because of this.\nIn that case, just\n\n    |> Bits.takeAtMost n\n    |> ArraySized.minTo n\n    |> ArraySized.maxTo n\n\nTo give the `ArraySized`'s _type_ more information\n\n","type":"N.N (N.Exactly (N.On newLength)) -> ArraySized.ArraySized Bit.Bit (N.In (N.On min_) max_) -> ArraySized.ArraySized Bit.Bit (N.Exactly (N.On newLength))"},{"name":"toChunksOf","comment":" Pad the `ArraySized` of [`Bit`](Bit#Bit)s to chunks of a given length\n\n    import ArraySized\n    import Linear exposing (Direction(..))\n    import N exposing (n8)\n    import Bit exposing (Bit(..))\n\n    ArraySized.one O\n        |> Bits.toChunksOf n8\n        |> ArraySized.map ArraySized.toList\n        |> ArraySized.toList\n    --> [ [ O, O, O, O, O, O, O, O ] ]\n\n    ArraySized.l3 I I I\n        |> ArraySized.attach Up (ArraySized.l8 O I I I O I O O)\n        |> ArraySized.attach Up (ArraySized.l8 O I I I O I O O)\n        |> ArraySized.attach Up (ArraySized.l8 O I I I O I O O)\n        |> Bits.toChunksOf n8\n        |> ArraySized.map ArraySized.toList\n        |> ArraySized.toList\n    --> [ [ O, O, O, O, O, I, I, I ]\n    --> , [ O, I, I, I, O, I, O, O ]\n    --> , [ O, I, I, I, O, I, O, O ]\n    --> , [ O, I, I, I, O, I, O, O ]\n    --> ]\n\n[`O`](Bit#Bit)s at the beginning aren't removed from the original `ArraySized`\n\n","type":"N.N (N.Exactly (N.On (N.Add1 chunkLengthMinus1))) -> ArraySized.ArraySized Bit.Bit (N.In (N.On min_) (N.Up maxX N.To maxPlusX)) -> ArraySized.ArraySized (ArraySized.ArraySized Bit.Bit (N.Exactly (N.On (N.Add1 chunkLengthMinus1)))) (N.In (N.Up0 minX_) (N.Up maxX N.To (N.Add1 maxPlusX)))"},{"name":"toIntSigned","comment":" Create signed `Int`\nencoded in its **length as the `Int`'s bit size**\n\nEncoding as follows:\ngiven bit size `n`,\nencode in the range `-(2 ^ (n - 1))` → `2 ^ (n - 1) - 1`.\nFor example, bit size 5 ranges from -16 to 15\n\n    import ArraySized\n    import Bit exposing (Bit(..))\n    import N exposing (n5, n6)\n\n    ArraySized.l5 O I O I O |> Bits.toIntSigned\n    -- 5-bit `Int`\n    --> -6\n\n    ArraySized.l6 I O I O I O |> Bits.toIntSigned\n    -- 6-bit `Int`\n    --> 10\n\n[`padToAtLeast`](#padToAtLeast) to convert it to a higher-bit representation\n\n    import ArraySized\n    import Bit exposing (Bit(..))\n    import N exposing (n8)\n\n    ArraySized.l6 I O I O I O\n        |> Bits.padToAtLeast n8\n        |> Bits.toIntSigned\n    -- 8-bit `Int`\n    --> -128 + 42\n\n","type":"ArraySized.ArraySized Bit.Bit (N.In min_ (N.Up maxTo32_ N.To N.Local.N32)) -> Basics.Int"},{"name":"toN","comment":" Convert <= 32 bits into an unsigned integer: `N (Min (Up0 nX_))`\n\n    import N\n    import Bit exposing (Bit(..))\n    import ArraySized\n\n    ArraySized.l6 I O O I O I\n        |> Bits.toN\n        |> N.toInt\n    --> 37\n\n","type":"ArraySized.ArraySized Bit.Bit (N.In min_ (N.Up maxTo32_ N.To N.Local.N32)) -> N.N (N.Min (N.Up0 nX_))"},{"name":"unpad","comment":" Remove all [`O`](Bit#Bit) from the beginning until the first [`I`](Bit#Bit) is reached\n\n    import N exposing (n4, n14)\n    import Bit exposing (Bit(..))\n    import ArraySized\n\n    n14 |> Bits.fromN |> Bits.unpad |> ArraySized.toList\n    --> [ I, I, I, O ]\n\n","type":"ArraySized.ArraySized Bit.Bit (N.In (N.On min_) max) -> ArraySized.ArraySized Bit.Bit (N.In (N.Up0 minX_) max)"}],"binops":[]}]