[
    {
        "name": "Csv.Decode",
        "comment": "\n\n## Basic usage\n\nUsing `periodic/elm-csv` (which returns a `Result (List String) Csv`):\n\n    Csv.parse rawData |> Csv.Decode.decode myDecoder\n\nUsing `lovasoa/elm-csv` (which returns a plain `Csv`):\n\n    Csv.parse rawData |> Csv.Decode.decodeCsv myDecoder\n\nYou can define decoders based on field position or on header name. See \nexamples below.\n\n\n# Types\n@docs Csv, Decoder\n\n# Running\n@docs decode, decodeCsv\n\n# Defining\n@docs next, field, assertNext, assertField, maybe\n\n# Combining\n@docs andMap, oneOf, map\n\n# Errors\n@docs Errors\n\n",
        "unions": [
            {
                "name": "Decoder",
                "comment": "\nA value that encapsulates how to decode CSV records (`List String`)\n\n",
                "args": [
                    "a",
                    "b"
                ],
                "cases": []
            },
            {
                "name": "Errors",
                "comment": "\nErrors can either be\n\n  1. Errors passed through from the underlying CSV parsing (`CsvErrors`), or\n  2. Errors in decoding a list of parsed records to models (`DecodeErrors`)\n\nNote that the latter reports the record index together with the error message.\n\n",
                "args": [],
                "cases": [
                    [
                        "CsvErrors",
                        [
                            "List String"
                        ]
                    ],
                    [
                        "DecodeErrors",
                        [
                            "List ( Int, String )"
                        ]
                    ]
                ]
            }
        ],
        "aliases": [
            {
                "name": "Csv",
                "comment": "\nThe raw CSV data structure.\n\n",
                "args": [],
                "type": "{ headers : List String, records : List (List String) }"
            }
        ],
        "values": [
            {
                "name": "andMap",
                "comment": "\nDecode multiple fields.\n\n    decodeCsv \n        (assertField \"site\" \"blog\" \n            |> andMap (field \"id\" String.toInt)\n        ) \n        data\n   \n    -- { headers = [ \"site\", \"id\" ]\n    -- , records = [[\"blog\",\"35\"]] \n    -- }   ==>  Ok [35]\n    \n",
                "type": "Decoder b c -> Decoder a b -> Decoder a c"
            },
            {
                "name": "assertField",
                "comment": "\nDecode a named field if it matches the given string.\n\nThe same example above, but for header-based decoding:\n\n    type Mailing\n        = Letter Float\n        | Parcel Float Dimensions\n\n    decodeMailing : Decoder (Mailing -> a) a\n    decodeMailing =\n        oneOf\n            [ map Letter\n                  ( assertField \"type\" \"LETTER\"\n                      |> andMap (field \"weight\" String.toFloat)\n                  )\n            , map Parcel\n                  ( assertField \"type\" \"PARCEL\"\n                      |> andMap (field \"weight\" String.toFloat)\n                      |> andMap (field \"dimensions\"  parseDimensions)\n                  )\n            ]\n\n",
                "type": "String -> String -> Decoder a a"
            },
            {
                "name": "assertNext",
                "comment": "\nDecode the next field if it matches the given string.\n\nThis can be useful to decode a union type based on a field of the CSV.\nFor example:\n\n    type Mailing\n        = Letter Float\n        | Parcel Float Dimensions\n\n    decodeMailing : Decoder (Mailing -> a) a\n    decodeMailing =\n        oneOf\n            [ map Letter\n                  ( assertNext \"LETTER\"\n                      |> andMap (next String.toFloat)\n                  )\n            , map Parcel\n                  ( assertNext \"PARCEL\"\n                      |> andMap (next String.toFloat)\n                      |> andMap (next parseDimensions)\n                  )\n            ]\n\n(Note: If you are familiar with the `url-parser` library, this is structurally\nsimilar to the `s` function.)\n\n",
                "type": "String -> Decoder a a"
            },
            {
                "name": "decode",
                "comment": "\nDecode the raw result of CSV parsing.\n\nTypically you chain them together like this (using `periodic/elm-csv`):\n\n    Csv.parse rawData |> Csv.Decode.decode myDecoder\n\n",
                "type": "Decoder (a -> a) a -> Result (List String) Csv -> Result Errors (List a)"
            },
            {
                "name": "decodeCsv",
                "comment": "\nDecode raw CSV data.\n\nThis is useful if you already have a `Csv` structure not\nwrapped in a `Result`, for instance `lovasoa/elm-csv` parses CSV strings this\nway.\n\n",
                "type": "Decoder (a -> a) a -> Csv -> Result Errors (List a)"
            },
            {
                "name": "field",
                "comment": "\nDecode the named field from the input: header-based decoding.\n\nUse this when you do not want to rely on the order of the fields, or when your\nsource fields map to more than one target field.\n\n    type alias Nutrition =\n       { name : String, calories : Int, protein : Float }\n\n    decodeNutrition : Decoder (Nutrition -> a) a\n    decodeNutrition =\n        map Nutrition\n            ( field \"name\" Ok\n                |> andMap (field \"calories\"  String.toInt)\n                |> andMap (field \"protein\" String.toFloat)\n            )\n\nNote that position- and header-based decoding can be combined, but it is not\ngenerally recommended.\n\n",
                "type": "String -> (String -> Result String a) -> Decoder (a -> b) b"
            },
            {
                "name": "map",
                "comment": "\nTransform a decoder.\n\nTypically used to feed a bunch of parsed state into a type constructor.\n\n    type alias Comment = { author : String, id : Int }\n    \n    decodeRawComment : Decoder (String -> Int -> a) a\n    decodeRawComment =\n        field \"author\" Ok |> andMap (field \"id\" String.toInt)\n\n    decodeComment : Decoder (Comment -> a) a\n    decodeComment =\n        map Comment decodeRawComment\n        \n",
                "type": "a -> Decoder a b -> Decoder (b -> c) c"
            },
            {
                "name": "maybe",
                "comment": "\nA convenience function for converting empty strings to `Nothing`.\nUseful when you have optional fields.\n\n    type alias Letter =\n        { weight = Float\n        , insurance = Maybe CurrencyAmount\n        }\n\n    decodeLetter : Decoder (Letter -> a) a\n    decodeLetter =\n        map Letter\n            ( field \"weight\" String.toFloat\n                |> andMap (field \"insurance\"  (maybe parseCurrencyAmount))\n            )\n\n",
                "type": "(String -> Result String a) -> String -> Result String (Maybe a)"
            },
            {
                "name": "next",
                "comment": "\nDecode the next field from the input: positional decoding.\n\nUse this when you are certain of the order of the fields. It is faster than\nheader-based decoding.\n\n    type alias Coordinates =\n        { x : Float, y : Float, z : Float }\n\n    decodeCoordinates : Decoder (Coordinates -> a) a\n    decodeCoordinates =\n        map Coordinates\n            ( next String.toFloat\n                |> andMap (next String.toFloat)\n                |> andMap (next String.toFloat)\n            )\n",
                "type": "(String -> Result String a) -> Decoder (a -> b) b"
            },
            {
                "name": "oneOf",
                "comment": "\nTry a bunch of different decoders, using the first one that succeeds.\n\n    type IntOrFloat\n       = Int_ Int\n       | Float_ Float\n\n    decode : Decoder (IntOrFloat -> a) a\n    decode =\n        oneOf\n          [ map Int_ <| next String.toInt\n          , map Float_ <| next String.toFloat\n          ]\n\n",
                "type": "List (Decoder a b) -> Decoder a b"
            }
        ],
        "binops": []
    }
]