[{"name":"Update.Pipeline","comment":" Sequential composition of updates facilitated by the pipe operator.\n\n\n# Basics\n\n@docs save, map, addCmd, mapCmd, join, equals\n\n\n# Chaining Updates\n\nThese functions enable composition of updates by chaining together functions of the type `a -> ( b, Cmd msg )`.\n\n@docs andThen, sequence, when, kleisli\n\n\n# Applicative Interface\n\nThese functions address the need to map functions with more than one parameter over `( model, Cmd msg )` inputs.\n\n@docs map2, map3, map4, map5, map6, map7, andMap\n\n\n# Pointfree Helpers\n\n\n### A note about pointfree style and η-reduction\n\nThanks to currying, in Elm we can often omit function arguments:\n\n    f1 x = g x      <==>  f1 = g\n    f2 x = g (h x)  <==>  f2 = g << h\n\nMaking the arguments implicit in this way allows the programmer to think about the program more abstractly, and can (sometimes) lead to more readable program code.\n\n\n### Pointfree:\n\n    update : Msg -> Model -> ( Model, Cmd Msg )\n    update msg =\n        case msg of\n            ButtonClicked ->\n                setMessage \"The button was clicked!\"\n                    >> andThen haveCoffee\n\n\n### Pointful:\n\n    update msg model =\n        case msg of\n            ButtonClicked ->\n                model\n                    |> setMessage \"The button was clicked!\"\n                    |> andThen haveCoffee\n\n@docs using, with\n\n\n# Shortcuts\n\n@docs andAddCmd, andUsing, andWith, andThenIf\n\n","unions":[],"aliases":[],"values":[{"name":"addCmd","comment":" Create a `( model, Cmd msg)` pair from the two arguments.\nThe implementation of this function is not very exciting — it is simply defined as `addCmd cmd model = ( model, cmd )` — but it can still be quite useful in idiomatic code.\nFor example, one could write\n\n    { model | power = 100 }\n        |> addCmd someCmd\n        |> andThen (setStatus Done)\n\n… instead of\n\n    ( { model | power = 100 }, someCmd )\n        |> andThen (setStatus Done)\n\nSee also [`andAddCmd`](#andAddCmd).\n\n","type":"Platform.Cmd.Cmd msg -> a -> ( a, Platform.Cmd.Cmd msg )"},{"name":"andAddCmd","comment":" This function is a shortcut for `andThen <<`[`addCmd`](#addCmd).\n\nExample use:\n\n    model\n        |> save\n        |> andAddCmd someCmd\n\n","type":"Platform.Cmd.Cmd msg -> ( a, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"andMap","comment":" Trying to map a function `(+) : number -> number -> number` over two `( model, Cmd msg)` inputs; first applying it to the first value\n\n    map (+) (save 4)\n\n… we end up with a result of type `( (number -> number), Cmd msg )`.\nTo apply the function inside this value to another `( number, Cmd msg )` value, we use this function in the following way:\n\n    map (+) (save 4) |> andMap (save 5)\n\nIn `elm repl`, we can verify that the result is what we expect:\n\n    > Tuple.first <| (map (+) (save 4) |> andMap (save 5))\n    9 : number\n\nThis pattern scales in a nice way to functions of any number of arguments.\n\nSee also [`map2`](#map2), [`map3`](#map3), etc. If not sooner, you’ll need this function when you want to `mapN` for _N > 7_.\n\n","type":"( a, Platform.Cmd.Cmd msg ) -> ( a -> b, Platform.Cmd.Cmd msg ) -> ( b, Platform.Cmd.Cmd msg )"},{"name":"andThen","comment":" When used in conjunction with the pipe operator, this combinator extracts the model from a `( model, Cmd msg )` value and passes it as input to the next function in a pipeline.\nFor example;\n\n    model\n        |> setPower 100\n        |> andThen (setDone True)\n\nMonadic functions of type `a -> ( b, Cmd msg )` are the building blocks of a pipeline.\nFor instance, the type of `setPower` in the above example is `Int -> Model -> ( Model, Cmd Msg )`.\n\n","type":"(b -> ( a, Platform.Cmd.Cmd msg )) -> ( b, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"andThenIf","comment":" This function is a shortcut for `\\cond -> andThen <<`[`when`](#when)`cond`.\n\n    model\n        |> save\n        |> andThenIf (power > 100) (setWarning Overflow)\n\n","type":"Basics.Bool -> (a -> ( a, Platform.Cmd.Cmd msg )) -> ( a, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"andUsing","comment":" Shortcut for `andThen <<`[`using`](#using).\n","type":"(b -> b -> ( a, Platform.Cmd.Cmd msg )) -> ( b, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"andWith","comment":" Shortcut for `\\view -> andThen <<`[`with`](#with)`view`.\n","type":"(b -> c) -> (c -> b -> ( a, Platform.Cmd.Cmd msg )) -> ( b, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"equals","comment":" Compare the models of two `( model, Cmd msg)` values.\n\nNote that the presence of effects means that\n\n    > (save 9) == (map2 (^) (save 3) (save 2))\n    False : Bool\n\nThis function can be used for comparison when only the model is of interest:\n\n    > equals (save 9) (map2 (^) (save 3) (save 2))\n    True : Bool\n\n","type":"( a, Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg ) -> Basics.Bool"},{"name":"join","comment":" Remove one level of structure that results from composing functions of the form `a -> ( b, Cmd msg )`:\n\n    f : a -> ( b, Cmd msg )\n    g : b -> ( c, Cmd mgs )\n\n    map g << f : a -> ( ( c, Cmd msg ), Cmd msg )\n\nIt is useful to know that [`andThen`](#andThen) is defined as `\\f -> join << map f`.\n\n","type":"( ( a, Platform.Cmd.Cmd msg ), Platform.Cmd.Cmd msg ) -> ( a, Platform.Cmd.Cmd msg )"},{"name":"kleisli","comment":" Right-to-left composition of two functions that return `( model, Cmd msg )` values, passing the first component of the first return value as input to the second function.\n\nThis is analogous to ordinary function composition in the following way:\n\n    (<<) : (b -> c) -> (a -> b) -> a -> c\n\n    kleisli : (b -> ( c, Cmd msg )) -> (a -> ( b, Cmd msg )) -> a -> ( c, Cmd msg )\n\n","type":"(b -> ( c, Platform.Cmd.Cmd msg )) -> (a -> ( b, Platform.Cmd.Cmd msg )) -> a -> ( c, Platform.Cmd.Cmd msg )"},{"name":"map","comment":" Apply a function to the model (i.e. first component) of a `( model, Cmd msg )` pair.\nPartially applied, we can also think of this as taking a function `a -> b` and _lifting_ it into one of type `( a, Cmd msg ) -> ( b, Cmd msg )`.\n","type":"(a -> b) -> ( a, Platform.Cmd.Cmd msg ) -> ( b, Platform.Cmd.Cmd msg )"},{"name":"map2","comment":" Combine two `( model, Cmd msg )` values by applying a function of two arguments\nto their respective models.\n","type":"(p -> q -> r) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg )"},{"name":"map3","comment":" Combine three `( model, Cmd msg )` values by applying a function of three arguments\nto their respective models.\n","type":"(p -> q -> r -> s) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg ) -> ( s, Platform.Cmd.Cmd msg )"},{"name":"map4","comment":" Combine four `( model, Cmd msg )` values by applying a function of four arguments\nto their respective models.\n","type":"(p -> q -> r -> s -> t) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg ) -> ( s, Platform.Cmd.Cmd msg ) -> ( t, Platform.Cmd.Cmd msg )"},{"name":"map5","comment":" Combine five `( model, Cmd msg )` values by applying a function of five arguments\nto their respective models.\n","type":"(p -> q -> r -> s -> t -> u) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg ) -> ( s, Platform.Cmd.Cmd msg ) -> ( t, Platform.Cmd.Cmd msg ) -> ( u, Platform.Cmd.Cmd msg )"},{"name":"map6","comment":" Combine six `( model, Cmd msg )` values by applying a function of six arguments\nto their respective models.\n","type":"(p -> q -> r -> s -> t -> u -> v) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg ) -> ( s, Platform.Cmd.Cmd msg ) -> ( t, Platform.Cmd.Cmd msg ) -> ( u, Platform.Cmd.Cmd msg ) -> ( v, Platform.Cmd.Cmd msg )"},{"name":"map7","comment":" Combine seven `( model, Cmd msg )` values by applying a function of seven arguments\nto their respective models.\n","type":"(p -> q -> r -> s -> t -> u -> v -> w) -> ( p, Platform.Cmd.Cmd msg ) -> ( q, Platform.Cmd.Cmd msg ) -> ( r, Platform.Cmd.Cmd msg ) -> ( s, Platform.Cmd.Cmd msg ) -> ( t, Platform.Cmd.Cmd msg ) -> ( u, Platform.Cmd.Cmd msg ) -> ( v, Platform.Cmd.Cmd msg ) -> ( w, Platform.Cmd.Cmd msg )"},{"name":"mapCmd","comment":" Transform the message produced by the command inside a `( model, Cmd msg )` pair.\n","type":"(msg1 -> msg2) -> ( a, Platform.Cmd.Cmd msg1 ) -> ( a, Platform.Cmd.Cmd msg2 )"},{"name":"save","comment":" Inject a value into a `( model, Cmd msg )` pair without adding any commands.\n\n    save model =\n        ( model, Cmd.none )\n\n","type":"a -> ( a, Platform.Cmd.Cmd msg )"},{"name":"sequence","comment":" Take a list of `a -> ( a, Cmd msg )` functions and run them sequentially, in a left-to-right manner, with the second argument as input.\n","type":"List.List (a -> ( a, Platform.Cmd.Cmd msg )) -> a -> ( a, Platform.Cmd.Cmd msg )"},{"name":"using","comment":" This combinator is useful for writing code in pointfree style.\n\nConsider the following example:\n\n    goToPage : Int -> Model -> ( Model, Cmd msg )\n    goToPage = ...\n\n    nextPage model =\n        goToPage (model.currentPage + 1) model\n\nUsing this helper, the above code can be refactored as\n\n    nextPage =\n        using (\\{ currentPage } -> goToPage (currentPage + 1))\n\nSee also [`with`](#with), [`andUsing`](#andUsing).\n\n","type":"(a -> a -> b) -> a -> b"},{"name":"when","comment":" Run an update if the given condition is `True`, otherwise do nothing.\nFor example;\n\n    model\n        |> when (power > 100) (setWarning Overflow)\n\nSee also [`andThenIf`](#andThenIf).\n\n","type":"Basics.Bool -> (a -> ( a, Platform.Cmd.Cmd msg )) -> a -> ( a, Platform.Cmd.Cmd msg )"},{"name":"with","comment":" This combinator is useful for writing code in pointfree style.\n\nFor example, the following code;\n\n    model\n        |> updateSomething\n        |> andThen (\\newModel -> setCounterValue (newModel.counter + 1) newModel)\n\n… can be refactored as\n\n    model\n        |> updateSomething\n        |> andThen (with .counter (setCounterValue << (+) 1))\n\nSee also [`using`](#using), [`andWith`](#andWith).\n\n","type":"(a -> b) -> (b -> a -> c) -> a -> c"}],"binops":[]}]