[{"name":"Bytes.Decode.Branchable","comment":" Parse `Bytes` with custom error reporting and context tracking.\n\n\n# Running the decoder\n\n@docs Decoder, decode\n\n\n# Static decoders\n\n@docs succeed, fail\n\n\n# Basic decoders\n\n\n## Integers\n\n@docs unsignedInt8, unsignedInt16, unsignedInt32, signedInt8, signedInt16, signedInt32\n\n\n## Floats\n\n@docs float32, float64\n\n\n## Strings\n\n@docs string\n\n\n## Decoding Bytes\n\n@docs bytes\n\n\n# Transforming values\n\n@docs map, map2, map3, map4, map5\n\n\n# Combininig decoders\n\n@docs keep, ignore, skip\n\n\n# Advanced decoders\n\n@docs andThen, oneOf, repeat, loop\n\n","unions":[{"name":"Decoder","comment":" A decoder for a certain type of value.\n","args":["value"],"cases":[]}],"aliases":[],"values":[{"name":"andThen","comment":" Decode one thing, and then another thing based on the first thing.\n\nThis is very useful to make the content of your data drive your decoder. As an\nexample, consider a string encoded as the length of the string, followed by the\nactual data:\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    string : Decoder String\n    string =\n        D.unsignedInt8\n            |> D.andThen D.string\n\n    [ E.unsignedInt8 5\n    , E.string \"hello\"\n    ]\n        |> E.sequence\n        |> E.encode\n        |> D.decode string\n    --> Just \"hello\"\n\n","type":"(a -> Bytes.Decode.Branchable.Decoder b) -> Bytes.Decode.Branchable.Decoder a -> Bytes.Decode.Branchable.Decoder b"},{"name":"bytes","comment":" Parse `count` bytes as `Bytes`.\n","type":"Basics.Int -> Bytes.Decode.Branchable.Decoder Bytes.Bytes"},{"name":"decode","comment":" Run the given decoder on the provided bytes.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D\n\n    E.string \"hello\"\n        |> E.encode\n        |> D.decode (D.string 5)\n    --> Just \"hello\"\n\n    E.string \"hello\"\n        |> E.encode\n        |> D.decode (D.string 6)\n    --> Nothing\n\n","type":"Bytes.Decode.Branchable.Decoder value -> Bytes.Bytes -> Maybe.Maybe value"},{"name":"fail","comment":" A Decoder that always fails.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D\n\n    E.sequence []\n        |> E.encode\n        |> D.decode D.fail\n    --> Nothing\n\n","type":"Bytes.Decode.Branchable.Decoder value"},{"name":"float32","comment":" Decode 4 bytes into a Float.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Float"},{"name":"float64","comment":" Decode 8 bytes into a Float.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Float"},{"name":"ignore","comment":" Ignore the value produced by a decoder.\n\nNote that the decoder must still succeed for the pipeline to succeed. This means\nyou can use this for checking the value of something, without using the value.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    match : Int -> Decoder Int\n    match expected =\n        D.unsignedInt8\n            |> D.andThen\n                (\\actual ->\n                    if expected == actual then\n                        D.succeed actual\n                    else\n                        D.fail\n                )\n\n    decoder : Decoder ()\n    decoder =\n        D.succeed ()\n            |> D.ignore (match 66)\n\n    E.unsignedInt8 66\n        |> E.encode\n        |> D.decode decoder\n    --> Just ()\n\n    E.unsignedInt8 44\n        |> E.encode\n        |> D.decode decoder\n    --> Nothing\n\n","type":"Bytes.Decode.Branchable.Decoder ignore -> Bytes.Decode.Branchable.Decoder keep -> Bytes.Decode.Branchable.Decoder keep"},{"name":"keep","comment":" Keep the value produced by a decoder in a pipeline.\n\nTogether with [`succeed`](#succeed) and [`ignore`](#ignore), this allows writing\npretty flexible decoders in a straightforward manner: the order in which things\nare parsed is apparent.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    decoder : Decoder (Int, Int)\n    decoder =\n        D.succeed Tuple.pair\n            |> D.keep D.unsignedInt8\n            |> D.ignore D.unsignedInt8\n            |> D.keep D.unsignedInt8\n\n    [ E.unsignedInt8 12\n    , E.unsignedInt8 3\n    , E.unsignedInt8 45\n    ]\n        |> E.sequence\n        |> E.encode\n        |> D.decode decoder\n    --> Just ( 12, 45 )\n\n","type":"Bytes.Decode.Branchable.Decoder a -> Bytes.Decode.Branchable.Decoder (a -> b) -> Bytes.Decode.Branchable.Decoder b"},{"name":"loop","comment":" Loop a decoder until it declares it is done looping.\n\nThe `Step` type in the signature comes from the `Bytes.Decode` module in elm/bytes.\nHere is how `repeat` is defined for example.\n\n    import Bytes.Decode\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    repeat : Decoder value -> Int -> Decoder (List value)\n    repeat p count =\n        D.loop ( count, [] ) (repeatHelp p)\n\n    repeatHelp p ( count, acc ) =\n        if count <= 0 then\n            succeed (Bytes.Decode.Done (List.reverse acc))\n\n        else\n            map (\\v -> Bytes.Decode.Loop ( count - 1, v :: acc )) p\n\n","type":"state -> (state -> Bytes.Decode.Branchable.Decoder (Bytes.Decode.Step state a)) -> Bytes.Decode.Branchable.Decoder a"},{"name":"map","comment":" Transform the value a decoder produces\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D\n\n    E.string \"hello\"\n        |> E.encode\n        |> D.decode (D.map String.length (D.string 5))\n    --> Just 5\n\n","type":"(a -> b) -> Bytes.Decode.Branchable.Decoder a -> Bytes.Decode.Branchable.Decoder b"},{"name":"map2","comment":" Combine two decoders into a single one.\n\n    import Bytes exposing (Bytes)\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    input : Bytes\n    input =\n        [ E.unsignedInt8 2\n        , E.string \"wat\"\n        ]\n            |> E.sequence\n            |> E.encode\n\n    map2Example : Decoder String\n    map2Example =\n        D.map2 String.repeat D.unsignedInt8 (D.string 3)\n\n    D.decode map2Example input\n    --> Just \"watwat\"\n\nNote that the effect of `map2` (and, in fact, every `map` variation) can also be\nachieved using a combination of [`succeed`](#succeed) and [`keep`](#keep).\n\n    equivalent : Decoder String\n    equivalent =\n        D.succeed String.repeat\n            |> D.keep D.unsignedInt8\n            |> D.keep (D.string 3)\n\n    D.decode equivalent input\n    --> Just \"watwat\"\n\n","type":"(x -> y -> z) -> Bytes.Decode.Branchable.Decoder x -> Bytes.Decode.Branchable.Decoder y -> Bytes.Decode.Branchable.Decoder z"},{"name":"map3","comment":" Combine 3 decoders into a single one.\n","type":"(w -> x -> y -> z) -> Bytes.Decode.Branchable.Decoder w -> Bytes.Decode.Branchable.Decoder x -> Bytes.Decode.Branchable.Decoder y -> Bytes.Decode.Branchable.Decoder z"},{"name":"map4","comment":" Combine 4 decoders into a single one.\n","type":"(v -> w -> x -> y -> z) -> Bytes.Decode.Branchable.Decoder v -> Bytes.Decode.Branchable.Decoder w -> Bytes.Decode.Branchable.Decoder x -> Bytes.Decode.Branchable.Decoder y -> Bytes.Decode.Branchable.Decoder z"},{"name":"map5","comment":" Combine 5 decoders into a single one.\n","type":"(u -> v -> w -> x -> y -> z) -> Bytes.Decode.Branchable.Decoder u -> Bytes.Decode.Branchable.Decoder v -> Bytes.Decode.Branchable.Decoder w -> Bytes.Decode.Branchable.Decoder x -> Bytes.Decode.Branchable.Decoder y -> Bytes.Decode.Branchable.Decoder z"},{"name":"oneOf","comment":" Tries a bunch of decoders and succeeds with the first one to succeed.\n\nAll decoder alternatives start at the same location in the bytes.\n\n","type":"List.List (Bytes.Decode.Branchable.Decoder value) -> Bytes.Decode.Branchable.Decoder value"},{"name":"repeat","comment":" Repeat a given decoder `count` times.\n\nThe order of arguments is based on the common occurence of reading the number of\ntimes to repeat something through a decoder.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D exposing (Decoder)\n\n    intList : Decoder (List Int)\n    intList =\n        D.unsignedInt8\n            |> D.andThen (D.repeat D.unsignedInt8)\n\n    [ 5, 0, 1, 2, 3, 4 ]\n        |> List.map E.unsignedInt8\n        |> E.sequence\n        |> E.encode\n        |> D.decode intList\n    --> Just [ 0, 1, 2, 3, 4 ]\n\n","type":"Bytes.Decode.Branchable.Decoder value -> Basics.Int -> Bytes.Decode.Branchable.Decoder (List.List value)"},{"name":"signedInt16","comment":" Decode two bytes into an integer from -32768 to 32767.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Int"},{"name":"signedInt32","comment":" Decode four bytes into an integer from -2147483648 to 2147483647.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Int"},{"name":"signedInt8","comment":" Decode one byte into an integer from -128 to 127.\n","type":"Bytes.Decode.Branchable.Decoder Basics.Int"},{"name":"skip","comment":" Skip a number of bytes in a pipeline.\n\nThis is similar to `ignore`, but rather than decoding a value and discarding it,\nthis just goes ahead and skips them altogether.\n\n","type":"Basics.Int -> Bytes.Decode.Branchable.Decoder value -> Bytes.Decode.Branchable.Decoder value"},{"name":"string","comment":" Decode `count` bytes representing UTF-8 characters into a String.\n\nNote that Elm strings use UTF-16. As a result, the `String.length` will not\nalways agree with the number of bytes that went into it!\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D\n\n    [ 0xF0, 0x9F, 0x91, 0x8D ]\n        |> List.map E.unsignedInt8\n        |> E.sequence\n        |> E.encode\n        |> D.decode (D.string 4)\n    --> Just \"👍\"\n\n","type":"Basics.Int -> Bytes.Decode.Branchable.Decoder String.String"},{"name":"succeed","comment":" Always succeed with the given value.\n\n    import Bytes.Encode as E\n    import Bytes.Decode.Branchable as D\n\n    E.encode (E.sequence [])\n        |> D.decode (D.succeed \"hi there\")\n    --> Just \"hi there\"\n\n","type":"value -> Bytes.Decode.Branchable.Decoder value"},{"name":"unsignedInt16","comment":" Decode two bytes into an integer from 0 to 65535.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Int"},{"name":"unsignedInt32","comment":" Decode four bytes into an integer from 0 to 4294967295.\n","type":"Bytes.Endianness -> Bytes.Decode.Branchable.Decoder Basics.Int"},{"name":"unsignedInt8","comment":" Decode one byte into an integer from 0 to 255.\n","type":"Bytes.Decode.Branchable.Decoder Basics.Int"}],"binops":[]}]