[
    {
        "name": "RemoteData",
        "comment": " A datatype representing fetched data.\n\nIf you find yourself continually using `Maybe (Result Error a)` to\nrepresent loaded data, or you have a habit of shuffling errors away to\nwhere they can be quietly ignored, consider using this. It makes it\neasier to represent the real state of a remote data fetch and handle\nit properly.\n\n\nFor more on the motivation, take a look at the blog post [How Elm Slays A UI Antipattern](http://blog.jenkster.com/2016/06/how-elm-slays-a-ui-antipattern.html).\n\n\nTo use the datatype, let's look at an example that loads `News` from a feed.\n\nFirst you add to your model, wrapping the data you want in `WebData`:\n\n\n    type alias Model =\n        { news : WebData News }\n\n\nThen add in a message that will deliver the response:\n\n\n    type alias Msg\n        = NewsResponse (WebData News)\n\n\nNow we can create an HTTP get:\n\n\n    getNews : Cmd Msg\n    getNews =\n        Http.get decodeNews \"/news\"\n            |> RemoteData.asCmd\n            |> Cmd.map NewsResponse\n\n\nWe trigger it in our `init` function:\n\n\n    init : ( Model, Cmd Msg)\n    init =\n        ( { news = Loading }\n        , getNews\n        )\n\n\nWe handle it in our `update` function:\n\n\n    update msg model =\n        case msg of\n            NewsResponse response ->\n                ( { model | news = response }\n                , Cmd.none\n                )\n\n\n\nMost of this you'd already have in your app, and the changes are just\nwrapping the datatype in `Webdata`, and updating the `Http.get` call\nto add in `RemoteData.asCmd`.\n\nNow we get to where we really want to be, rendering the data and\nhandling the different states in the UI gracefully:\n\n\n    view : Model -> Html msg\n    view model =\n      case model.news of\n        NotAsked -> text \"Initialising.\"\n\n        Loading -> text \"Loading.\"\n\n        Failure err -> text (\"Error: \" ++ toString err)\n\n        Success news -> viewNews news\n\n\n    viewNews : News -> Html msg\n    viewNews news =\n        div []\n            [h1 [] [text \"Here is the news.\"]\n            , ...]\n\n@docs RemoteData\n@docs WebData\n@docs map\n@docs mapFailure\n@docs mapBoth\n@docs andThen\n@docs withDefault\n@docs fromResult\n@docs asCmd\n@docs fromTask\n@docs append\n@docs isSuccess\n@docs update\n\n",
        "unions": [
            {
                "name": "RemoteData",
                "comment": " Frequently when you're fetching data from an API, you want to represent four different states:\n  * `NotAsked` - We haven't asked for the data yet.\n  * `Loading` - We've asked, but haven't got an answer yet.\n  * `Failure` - We asked, but something went wrong. Here's the error.\n  * `Success` - Everything worked, and here's the data.\n",
                "args": [
                    "e",
                    "a"
                ],
                "cases": [
                    [
                        "NotAsked",
                        []
                    ],
                    [
                        "Loading",
                        []
                    ],
                    [
                        "Failure",
                        [
                            "e"
                        ]
                    ],
                    [
                        "Success",
                        [
                            "a"
                        ]
                    ]
                ]
            }
        ],
        "aliases": [
            {
                "name": "WebData",
                "comment": " While `RemoteData` can model any type of error, the most common\none you'll actually encounter is when you fetch data from a REST\ninterface, and get back `RemoteData Http.Error a`. Because that case\nis so common, `WebData` is provided as a useful alias.\n",
                "args": [
                    "a"
                ],
                "type": "RemoteData Error a"
            }
        ],
        "values": [
            {
                "name": "andThen",
                "comment": " Chain together RemoteData function calls.\n",
                "type": "RemoteData e a -> (a -> RemoteData e b) -> RemoteData e b"
            },
            {
                "name": "append",
                "comment": " Append - join two `RemoteData` values together as though\nthey were one.\n\nIf their value is `NotAsked`, the result is `NotAsked`.\nIf their value is `Loading`, the result is `Loading`.\nIf both values are `Failure`, the left one wins.\n",
                "type": "RemoteData e a -> RemoteData e b -> RemoteData e ( a, b )"
            },
            {
                "name": "asCmd",
                "comment": " Convert a web `Task`, probably produced from elm-http, to a `Cmd (RemoteData e a)`.\n",
                "type": "Task e a -> Cmd (RemoteData e a)"
            },
            {
                "name": "fromResult",
                "comment": " Convert a `Result Error`, probably produced from elm-http, to a RemoteData value.\n",
                "type": "Result e a -> RemoteData e a"
            },
            {
                "name": "fromTask",
                "comment": " Convert from a `Task` that may succeed or fail, to one that always\nsucceeds with the `RemoteData` that captures any errors.\n",
                "type": "Task e a -> Task Never (RemoteData e a)"
            },
            {
                "name": "isSuccess",
                "comment": " State-checking predicate. Returns true if we've successfully loaded some data.\n",
                "type": "RemoteData e a -> Bool"
            },
            {
                "name": "map",
                "comment": " Map a function into the `Success` value.\n",
                "type": "(a -> b) -> RemoteData e a -> RemoteData e b"
            },
            {
                "name": "mapBoth",
                "comment": " Map function into both the `Success` and `Failure` value.\n",
                "type": "(a -> b) -> (e -> f) -> RemoteData e a -> RemoteData f b"
            },
            {
                "name": "mapFailure",
                "comment": " Map a function into the `Failure` value.\n",
                "type": "(e -> f) -> RemoteData e a -> RemoteData f a"
            },
            {
                "name": "update",
                "comment": " Apply an Elm update function - `Model -> (Model, Cmd Msg)` - to any `Successful`-ly loaded data.\n\nIt's quite common in Elm to want to run a model-update function, over\nsome remote data, but only once it's actually been loaded.\n\nFor example, we might want to handle UI messages changing the users\nsettings, but that only makes sense once those settings have been\nreturned from the server.\n\nThis function makes it more convenient to reach inside a\n`RemoteData.Success` value and apply an update. If the data in not\n`Success a`, it is return unchanged with a `Cmd.none`.\n\n",
                "type": "(a -> ( a, Cmd b )) -> RemoteData e a -> ( RemoteData e a, Cmd b )"
            },
            {
                "name": "withDefault",
                "comment": " Return the `Success` value, or the default.\n",
                "type": "a -> RemoteData e a -> a"
            }
        ],
        "binops": []
    }
]