Safe Haskell | None |
---|---|
Language | Haskell2010 |
- sendRequestAsync :: StdMethod -> Text -> Maybe RequestBody -> Maybe ContentType -> IO (Async AjaxResponse)
- data AjaxResponse :: * = AjaxResponse {}
- data StdMethod :: *
- type RequestBody = Text
- type ContentType = Text
- data Async a :: * -> *
- wait :: Async a -> IO a
- waitCatch :: Async a -> IO (Either SomeException a)
- cancel :: Async a -> IO ()
Documentation
sendRequestAsync :: StdMethod -> Text -> Maybe RequestBody -> Maybe ContentType -> IO (Async AjaxResponse) Source #
Send an ajax request provided a HTTP-Method, a target url, optional a request body and content type
data AjaxResponse :: * #
HTTP standard method (as defined by RFC 2616, and PATCH which is defined by RFC 5789).
type RequestBody = Text #
type ContentType = Text #
Wait for an asynchronous action to complete, and return its
value. If the asynchronous action threw an exception, then the
exception is re-thrown by wait
.
wait = atomically . waitSTM
waitCatch :: Async a -> IO (Either SomeException a) #
Wait for an asynchronous action to complete, and return either
Left e
if the action raised an exception e
, or Right a
if it
returned a value a
.
waitCatch = atomically . waitCatchSTM
Cancel an asynchronous action by throwing the ThreadKilled
exception to it. Has no effect if the Async
has already
completed.
cancel a = throwTo (asyncThreadId a) ThreadKilled
Note that cancel
is synchronous in the same sense as throwTo
.
It does not return until the exception has been thrown in the
target thread, or the target thread has completed. In particular,
if the target thread is making a foreign call, the exception will
not be thrown until the foreign call returns, and in this case
cancel
may block indefinitely. An asynchronous cancel
can
of course be obtained by wrapping cancel
itself in async
.