[{"name":"Thread.Browser","comment":" [Browser](https://package.elm-lang.org/packages/elm/browser/latest/Browser) alternatives.\n\nIf your needs cannot be met by this module, use the low level functions of [`Thread.Procedure`](https://package.elm-lang.org/packages/arowM/elm-thread/latest/Thread-Procedure).\n\n@docs element\n@docs document\n@docs application\n@docs Program\n@docs Document\n@docs Model\n@docs Msg\n\n","unions":[],"aliases":[{"name":"Document","comment":" Reexport [Browser.Document](https://package.elm-lang.org/packages/elm/browser/latest/Browser#Document) for convenience.\n","args":["global"],"type":"Browser.Document global"},{"name":"Model","comment":" Reexport `Thread.Procedure.Model` for convenience.\n","args":["shared","global","local"],"type":"Thread.Procedure.Model shared global local"},{"name":"Msg","comment":" Reexport `Thread.Procedure.Msg` for convenience.\n","args":["global","local"],"type":"Thread.Procedure.Msg global local"},{"name":"Program","comment":" An alias for [Platform.Program](https://package.elm-lang.org/packages/elm/core/latest/Platform#Program).\n","args":["flags","shared","global","local"],"type":"Platform.Program flags (Thread.Browser.Model shared global local) (Thread.Browser.Msg global local)"}],"values":[{"name":"application","comment":" Threads version of [Browser.application](https://package.elm-lang.org/packages/elm/browser/latest/Browser#application)\n","type":"{ init : shared, procedure : flags -> Url.Url -> Browser.Navigation.Key -> Thread.Procedure.Procedure shared global local, view : shared -> Thread.Browser.Document global, subscriptions : shared -> Platform.Sub.Sub global, onUrlRequest : Browser.UrlRequest -> global, onUrlChange : Url.Url -> global } -> Thread.Browser.Program flags shared global local"},{"name":"document","comment":" Threads version of [Browser.document](https://package.elm-lang.org/packages/elm/browser/latest/Browser#document)\n","type":"{ init : shared, procedure : flags -> Thread.Procedure.Procedure shared global local, view : shared -> Thread.Browser.Document global, subscriptions : shared -> Platform.Sub.Sub global } -> Thread.Browser.Program flags shared global local"},{"name":"element","comment":" Threads version of [Browser.element](https://package.elm-lang.org/packages/elm/browser/latest/Browser#element)\n","type":"{ init : shared, procedure : flags -> Thread.Procedure.Procedure shared global local, view : shared -> Html.Html global, subscriptions : shared -> Platform.Sub.Sub global } -> Thread.Browser.Program flags shared global local"}],"binops":[]},{"name":"Thread.Lifter","comment":" Helper module for converting [`Procedure`](https://package.elm-lang.org/packages/arowM/elm-thread/latest/Thread-Procedure#Procedure).\n\n@docs Lifter\n@docs compose\n\n","unions":[],"aliases":[{"name":"Lifter","comment":" Use to convert shared memory types.\n","args":["a","b"],"type":"{ get : a -> b, set : b -> a -> a }"}],"values":[{"name":"compose","comment":" ","type":"Thread.Lifter.Lifter a b -> Thread.Lifter.Lifter b c -> Thread.Lifter.Lifter a c"}],"binops":[]},{"name":"Thread.Procedure","comment":"\n\n\n# Core\n\n@docs Procedure\n@docs batch\n\n\n# Constructors\n\n@docs none\n@docs modify\n@docs push\n@docs await\n@docs awaitGlobal\n@docs fork\n@docs syncAll\n@docs quit\n\n\n# Advanced constructors\n\n@docs modifyAndThen\n@docs lazy\n\n\n# Converters\n\nThese items are needed when you try to build a hierarchy of shared memory and events in an SPA.\nNote that the pattern often unnecessarily increases complexity, so you should first consider using monolithic shared memory and events.\n\nFor a sample, see [`sample/src/SPA.elm`](https://github.com/arowM/elm-thread/tree/main/sample/src).\n\n@docs liftShared\n@docs wrapLocal\n@docs wrapGlobal\n\n\n# Lower level functions\n\nIt is recommended to use `Thread.Browser` for normal use.\n\n@docs elementView\n@docs documentView\n@docs init\n@docs update\n@docs subscriptions\n@docs onUrlRequest\n@docs onUrlChange\n@docs Model\n@docs Msg\n@docs globalEvent\n\n","unions":[{"name":"Model","comment":" ","args":["shared","global","local"],"cases":[]},{"name":"Msg","comment":" ","args":["global","local"],"cases":[]},{"name":"Procedure","comment":" Procedures to be processed in a thread.\n\n  - shared: Shared memory\n  - global: Global events\n  - local: Local events that only affect on the forked thread itself\n\n","args":["shared","global","local"],"cases":[]}],"aliases":[],"values":[{"name":"await","comment":" Construct a `Procedure` instance that awaits the local events for the thread.\n\nIf it returns `Nothing`, it awaits again.\nOtherwise, it evaluates the given `Procedure`.\n\nNote1: The shared memory state passed to the first argument function may become outdated during running the thread for the `Procedure` generated by that function, so it is safe to use this shared memory state only to determine whether to accept or miss events.\n\nNote2: Technically, all the `modify` `push` `fork` written before the `await` will be executed internally as a single operation. This avoids the situation where a local event triggered by a `push` occurs while processing tons of subsequent `modify`s and `push`s, thus ensuring that the `await` always can catch the local event caused by the previous `Procedure`s.\n\nNote3: `push`s written before an `await` will not necessarily cause local events in the order written. For example, if the first `push` sends a request to the server and it fires a local event with its result, and the second `push` sleeps for 0.1 seconds and then returns a local event, the first local event can fire later if the server is slow to respond. To avoid this situation, after using one `push`, catch it with `await` and use the next `push`, or use `syncAll`.\n\n","type":"(local -> shared -> Maybe.Maybe (Thread.Procedure.Procedure shared global local)) -> Thread.Procedure.Procedure shared global local"},{"name":"awaitGlobal","comment":" Construct a `Procedure` instance that awaits global events.\n\nIf it returns `Nothing`, it awaits again.\nOtherwise, it evaluates the given `Procedure`.\n\nNote that the shared memory state passed to the first argument function may become outdated during running the thread for the `Procedure` generated by that function, so it is safe to use this shared memory state only to determine whether to accept or miss events.\n\n","type":"(global -> shared -> Maybe.Maybe (Thread.Procedure.Procedure shared global local)) -> Thread.Procedure.Procedure shared global local"},{"name":"batch","comment":" Batch `Procedure`s together. The elements are evaluated in order.\n","type":"List.List (Thread.Procedure.Procedure shared global local) -> Thread.Procedure.Procedure shared global local"},{"name":"documentView","comment":" ","type":"(shared -> Browser.Document global) -> Thread.Procedure.Model shared global local -> Browser.Document (Thread.Procedure.Msg global local)"},{"name":"elementView","comment":" ","type":"(shared -> Html.Html global) -> Thread.Procedure.Model shared global local -> Html.Html (Thread.Procedure.Msg global local)"},{"name":"fork","comment":" Construct a `Procedure` instance that evaluates the given `Procedure` in a forked thread.\n\nThe forked thread runs independently of the original thread.\ni.e., The subsequent `Procedure`s in the original thread are evaluated immediately.\n\n","type":"(() -> Thread.Procedure.Procedure shared global local) -> Thread.Procedure.Procedure shared global local"},{"name":"globalEvent","comment":" ","type":"global -> Thread.Procedure.Msg global local"},{"name":"init","comment":" ","type":"shared -> Thread.Procedure.Procedure shared global local -> ( Thread.Procedure.Model shared global local, Platform.Cmd.Cmd (Thread.Procedure.Msg global local) )"},{"name":"lazy","comment":" Sometimes you have `Procedure` with recursive structure, like awaiting events again.\nYou can use `lazy` to make sure your procedure unrolls lazily.\n\n    procedure : Procedure Shared Global Local\n    procedure =\n        Procedure.batch\n            [ putLog \"Thread started.\"\n            , Procedure.await <|\n                \\global _ ->\n                    case global of\n                        ChangeInput str ->\n                            Just <|\n                                Procedure.batch\n                                    [ Procedure.modify <|\n                                        \\shared ->\n                                            { shared | input = str }\n                                    , Procedure.lazy <| \\_ -> procedure\n                                    ]\n\n                        ClickSave ->\n                            Just <|\n                                Procedure.modify <|\n                                    \\shared ->\n                                        { shared\n                                            | input = \"\"\n                                            , saved = shared.saved ++ [ shared.input ]\n                                        }\n\n                        _ ->\n                            Nothing\n            ]\n\nYou can use `fork` for a similar purpose, but whereas `fork` creates a new thread for the given `Procedure` and the original thread proceeds immediately to the next `Procedure`, `lazy` does the given `Procedure` in the original thread and then proceeds to the subsequent `Procedure` after it is finished.\nThis property can be used to create threads that do not complete until the user input is complete. In combination with `modifyAndThen`, such threads are convenient for resource management. See [`sample/src/Advanced.elm`](https://github.com/arowM/elm-thread/tree/main/sample/src) and its [live demo](https://arowm.github.io/elm-thread/advanced.html) for more information.\n\n","type":"(() -> Thread.Procedure.Procedure shared global local) -> Thread.Procedure.Procedure shared global local"},{"name":"liftShared","comment":" ","type":"Thread.Lifter.Lifter a b -> Thread.Procedure.Procedure b global local -> Thread.Procedure.Procedure a global local"},{"name":"modify","comment":" Construct a `Procedure` instance that modifies shared memory state.\n\nThe update operation, passed as the first argument, is performed atomically. It means the state of shared memory read by a particular thread with `modify` is not updated by another thread until it is updated by the thread.\n\n","type":"(shared -> shared) -> Thread.Procedure.Procedure shared global local"},{"name":"modifyAndThen","comment":" Modify the shared memory atomically, creating the intermediate value in the process, and pass the value to another `Procedure`.\n\nThe intermediate value is supposed to be the identifier of the certain resource at a particular time.\ne.g., In an application that allows the user to select and edit the goat profile from a list of goat profiles, the information about \"which goat was selected\" can be the intermediate value.\n\nFor a sample, see [`sample/src/Advanced.elm`](https://github.com/arowM/elm-thread/tree/main/sample/src) and its [live demo](https://arowm.github.io/elm-thread/advanced.html).\n\n","type":"(shared -> ( shared, x )) -> (x -> Thread.Procedure.Procedure shared global local) -> Thread.Procedure.Procedure shared global local"},{"name":"none","comment":" Construct a `Procedure` instance that do nothing.\n","type":"Thread.Procedure.Procedure shared global local"},{"name":"onUrlChange","comment":" ","type":"(Url.Url -> global) -> Url.Url -> Thread.Procedure.Msg global local"},{"name":"onUrlRequest","comment":" ","type":"(Browser.UrlRequest -> global) -> Browser.UrlRequest -> Thread.Procedure.Msg global local"},{"name":"push","comment":" Construct a `Procedure` instance that pushes a local `Cmd`.\n","type":"(shared -> Platform.Cmd.Cmd local) -> Thread.Procedure.Procedure shared global local"},{"name":"quit","comment":" Quit the thread immediately.\n\nSubsequent `Procedures` are not evaluated and are discarded.\n\n","type":"Thread.Procedure.Procedure shared global local"},{"name":"subscriptions","comment":" ","type":"(shared -> Platform.Sub.Sub global) -> Thread.Procedure.Model shared global local -> Platform.Sub.Sub (Thread.Procedure.Msg global local)"},{"name":"syncAll","comment":" Construct a `Procedure` instance that wait for all given `Procedure`s to be completed.\n\nGiven `Procedure`s are evaluated in the independent thread, but the subsequent `Procedure`s in the original thread are **not** evaluated immediately.\n\n","type":"List.List (Thread.Procedure.Procedure shared global local) -> Thread.Procedure.Procedure shared global local"},{"name":"update","comment":" ","type":"Thread.Procedure.Msg global local -> Thread.Procedure.Model shared global local -> ( Thread.Procedure.Model shared global local, Platform.Cmd.Cmd (Thread.Procedure.Msg global local) )"},{"name":"wrapGlobal","comment":" ","type":"(a -> Maybe.Maybe b) -> Thread.Procedure.Procedure shared b local -> Thread.Procedure.Procedure shared a local"},{"name":"wrapLocal","comment":" ","type":"Thread.Wrapper.Wrapper a b -> Thread.Procedure.Procedure shared global b -> Thread.Procedure.Procedure shared global a"}],"binops":[]},{"name":"Thread.Wrapper","comment":" Helper module for converting [`Procedure`](https://package.elm-lang.org/packages/arowM/elm-thread/latest/Thread-Procedure#Procedure).\n\n@docs Wrapper\n@docs compose\n\n","unions":[],"aliases":[{"name":"Wrapper","comment":" Use to convert local event types.\n","args":["a","b"],"type":"{ unwrap : a -> Maybe.Maybe b, wrap : b -> a }"}],"values":[{"name":"compose","comment":" ","type":"Thread.Wrapper.Wrapper a b -> Thread.Wrapper.Wrapper b c -> Thread.Wrapper.Wrapper a c"}],"binops":[]}]