Safe Haskell | None |
---|---|
Language | Haskell98 |
This module provides RequesterT
, the standard implementation of
Requester
.
Synopsis
- newtype RequesterT t request (response :: * -> *) m a = RequesterT {
- unRequesterT :: StateT (RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
- runRequesterT :: (Reflex t, Monad m) => RequesterT t request response m a -> Event t (RequesterData response) -> m (a, Event t (RequesterData request))
- withRequesterT :: (Reflex t, MonadFix m) => (forall x. req x -> req' x) -> (forall x. rsp' x -> rsp x) -> RequesterT t req rsp m a -> RequesterT t req' rsp' m a
- runWithReplaceRequesterTWith :: forall m t request response a b. (Reflex t, MonadHold t m, MonadFix m) => (forall a' b'. m a' -> Event t (m b') -> RequesterT t request response m (a', Event t b')) -> RequesterT t request response m a -> Event t (RequesterT t request response m b) -> RequesterT t request response m (a, Event t b)
- traverseIntMapWithKeyWithAdjustRequesterTWith :: forall t request response m v v' p. (Reflex t, MonadHold t m, PatchTarget (p (Event t (IntMap (RequesterData request)))) ~ IntMap (Event t (IntMap (RequesterData request))), Patch (p (Event t (IntMap (RequesterData request)))), Functor p, MonadFix m) => ((Key -> (Key, v) -> m (Event t (IntMap (RequesterData request)), v')) -> IntMap (Key, v) -> Event t (p (Key, v)) -> RequesterT t request response m (IntMap (Event t (IntMap (RequesterData request)), v'), Event t (p (Event t (IntMap (RequesterData request)), v')))) -> (p (Event t (IntMap (RequesterData request))) -> IntMap (Event t (IntMap (RequesterData request)))) -> (Incremental t (p (Event t (IntMap (RequesterData request)))) -> Event t (IntMap (IntMap (RequesterData request)))) -> (Key -> v -> RequesterT t request response m v') -> IntMap v -> Event t (p v) -> RequesterT t request response m (IntMap v', Event t (p v'))
- traverseDMapWithKeyWithAdjustRequesterTWith :: forall k t request response m v v' p p'. (GCompare k, Reflex t, MonadHold t m, PatchTarget (p' (Some k) (Event t (IntMap (RequesterData request)))) ~ Map (Some k) (Event t (IntMap (RequesterData request))), Patch (p' (Some k) (Event t (IntMap (RequesterData request)))), MonadFix m) => (forall k' v1 v2. GCompare k' => (forall a. k' a -> v1 a -> m (v2 a)) -> DMap k' v1 -> Event t (p k' v1) -> RequesterT t request response m (DMap k' v2, Event t (p k' v2))) -> (forall v1 v2. (forall a. v1 a -> v2 a) -> p k v1 -> p k v2) -> (forall v1 v2. (forall a. v1 a -> v2) -> p k v1 -> p' (Some k) v2) -> (forall v2. p' (Some k) v2 -> Map (Some k) v2) -> (forall a. Incremental t (p' (Some k) (Event t a)) -> Event t (Map (Some k) a)) -> (forall a. k a -> v a -> RequesterT t request response m (v' a)) -> DMap k v -> Event t (p k v) -> RequesterT t request response m (DMap k v', Event t (p k v'))
- data RequesterData f
- data RequesterDataKey a
- traverseRequesterData :: forall m request response. Applicative m => (forall a. request a -> m (response a)) -> RequesterData request -> m (RequesterData response)
- forRequesterData :: forall request response m. Applicative m => RequesterData request -> (forall a. request a -> m (response a)) -> m (RequesterData response)
- requesterDataToList :: RequesterData f -> [DSum RequesterDataKey f]
- singletonRequesterData :: RequesterDataKey a -> f a -> RequesterData f
- matchResponsesWithRequests :: forall t rawRequest rawResponse request response m. (MonadFix m, MonadHold t m, Reflex t) => (forall a. request a -> (rawRequest, rawResponse -> response a)) -> Event t (RequesterData request) -> Event t (Int, rawResponse) -> m (Event t (Map Int rawRequest), Event t (RequesterData response))
- multiEntry :: IntMap (RequesterData f) -> Entry f Multi
- unMultiEntry :: Entry f Multi -> IntMap (RequesterData f)
- requesting' :: (MyTagTypeOffset x, Monad m) => Event t (Entry request x) -> RequesterT t request response m (Event t (Entry response x))
Documentation
newtype RequesterT t request (response :: * -> *) m a Source #
A basic implementation of Requester
.
RequesterT | |
|
Instances
MonadReader r m => MonadReader r (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base ask :: RequesterT t request response m r # local :: (r -> r) -> RequesterT t request response m a -> RequesterT t request response m a # reader :: (r -> a) -> RequesterT t request response m a # | |
MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base newEventWithTrigger :: (EventTrigger t a -> IO (IO ())) -> RequesterT t request response m (Event t a) Source # newFanEventWithTrigger :: GCompare k => (forall a. k a -> EventTrigger t a -> IO (IO ())) -> RequesterT t request response m (EventSelector t k) Source # | |
(Reflex t, Adjustable t m, MonadHold t m, MonadFix m) => Adjustable t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base runWithReplace :: RequesterT t request response m a -> Event t (RequesterT t request response m b) -> RequesterT t request response m (a, Event t b) Source # traverseIntMapWithKeyWithAdjust :: (Key -> v -> RequesterT t request response m v') -> IntMap v -> Event t (PatchIntMap v) -> RequesterT t request response m (IntMap v', Event t (PatchIntMap v')) Source # traverseDMapWithKeyWithAdjust :: GCompare k => (forall a. k a -> v a -> RequesterT t request response m (v' a)) -> DMap k v -> Event t (PatchDMap k v) -> RequesterT t request response m (DMap k v', Event t (PatchDMap k v')) Source # traverseDMapWithKeyWithAdjustWithMove :: GCompare k => (forall a. k a -> v a -> RequesterT t request response m (v' a)) -> DMap k v -> Event t (PatchDMapWithMove k v) -> RequesterT t request response m (DMap k v', Event t (PatchDMapWithMove k v')) Source # | |
PostBuild t m => PostBuild t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base getPostBuild :: RequesterT t request response m (Event t ()) Source # | |
(Reflex t, Monad m) => Requester t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base type Request (RequesterT t request response m) :: Type -> Type Source # type Response (RequesterT t request response m) :: Type -> Type Source # requesting :: Event t (Request (RequesterT t request response m) a) -> RequesterT t request response m (Event t (Response (RequesterT t request response m) a)) Source # requesting_ :: Event t (Request (RequesterT t request response m) a) -> RequesterT t request response m () Source # | |
TriggerEvent t m => TriggerEvent t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base newTriggerEvent :: RequesterT t request response m (Event t a, a -> IO ()) Source # newTriggerEventWithOnComplete :: RequesterT t request response m (Event t a, a -> IO () -> IO ()) Source # newEventWithLazyTriggerWithOnComplete :: ((a -> IO () -> IO ()) -> IO (IO ())) -> RequesterT t request response m (Event t a) Source # | |
PerformEvent t m => PerformEvent t (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base type Performable (RequesterT t request response m) :: Type -> Type Source # performEvent :: Event t (Performable (RequesterT t request response m) a) -> RequesterT t request response m (Event t a) Source # performEvent_ :: Event t (Performable (RequesterT t request response m) ()) -> RequesterT t request response m () Source # | |
NotReady t m => NotReady t (RequesterT t request response m) Source # | |
Defined in Reflex.NotReady.Class notReadyUntil :: Event t a -> RequesterT t request response m () Source # notReady :: RequesterT t request response m () Source # | |
MonadHold t m => MonadHold (t :: Type) (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base hold :: a -> Event t a -> RequesterT t request response m (Behavior t a) Source # holdDyn :: a -> Event t a -> RequesterT t request response m (Dynamic t a) Source # holdIncremental :: Patch p => PatchTarget p -> Event t p -> RequesterT t request response m (Incremental t p) Source # buildDynamic :: PushM t a -> Event t a -> RequesterT t request response m (Dynamic t a) Source # headE :: Event t a -> RequesterT t request response m (Event t a) Source # | |
MonadSample t m => MonadSample (t :: Type) (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base sample :: Behavior t a -> RequesterT t request response m a Source # | |
MonadTrans (RequesterT t request response) Source # | |
Defined in Reflex.Requester.Base lift :: Monad m => m a -> RequesterT t request response m a # | |
Monad m => Monad (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base (>>=) :: RequesterT t request response m a -> (a -> RequesterT t request response m b) -> RequesterT t request response m b # (>>) :: RequesterT t request response m a -> RequesterT t request response m b -> RequesterT t request response m b # return :: a -> RequesterT t request response m a # fail :: String -> RequesterT t request response m a # | |
Functor m => Functor (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base fmap :: (a -> b) -> RequesterT t request response m a -> RequesterT t request response m b # (<$) :: a -> RequesterT t request response m b -> RequesterT t request response m a # | |
MonadFix m => MonadFix (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base mfix :: (a -> RequesterT t request response m a) -> RequesterT t request response m a # | |
Monad m => Applicative (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base pure :: a -> RequesterT t request response m a # (<*>) :: RequesterT t request response m (a -> b) -> RequesterT t request response m a -> RequesterT t request response m b # liftA2 :: (a -> b -> c) -> RequesterT t request response m a -> RequesterT t request response m b -> RequesterT t request response m c # (*>) :: RequesterT t request response m a -> RequesterT t request response m b -> RequesterT t request response m b # (<*) :: RequesterT t request response m a -> RequesterT t request response m b -> RequesterT t request response m a # | |
MonadIO m => MonadIO (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base liftIO :: IO a -> RequesterT t request response m a # | |
MonadException m => MonadException (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base throw :: Exception e => e -> RequesterT t request response m a # catch :: Exception e => RequesterT t request response m a -> (e -> RequesterT t request response m a) -> RequesterT t request response m a # finally :: RequesterT t request response m a -> RequesterT t request response m b -> RequesterT t request response m a # | |
MonadAsyncException m => MonadAsyncException (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base mask :: ((forall a. RequesterT t request response m a -> RequesterT t request response m a) -> RequesterT t request response m b) -> RequesterT t request response m b # | |
PrimMonad m => PrimMonad (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base type PrimState (RequesterT t request response m) :: Type # primitive :: (State# (PrimState (RequesterT t request response m)) -> (#State# (PrimState (RequesterT t request response m)), a#)) -> RequesterT t request response m a # | |
MonadRef m => MonadRef (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base type Ref (RequesterT t request response m) :: Type -> Type # newRef :: a -> RequesterT t request response m (Ref (RequesterT t request response m) a) # readRef :: Ref (RequesterT t request response m) a -> RequesterT t request response m a # writeRef :: Ref (RequesterT t request response m) a -> a -> RequesterT t request response m () # modifyRef :: Ref (RequesterT t request response m) a -> (a -> a) -> RequesterT t request response m () # modifyRef' :: Ref (RequesterT t request response m) a -> (a -> a) -> RequesterT t request response m () # | |
(Semigroup a, Monad m) => Semigroup (RequesterT t request response m a) Source # | |
Defined in Reflex.Requester.Base (<>) :: RequesterT t request response m a -> RequesterT t request response m a -> RequesterT t request response m a # sconcat :: NonEmpty (RequesterT t request response m a) -> RequesterT t request response m a # stimes :: Integral b => b -> RequesterT t request response m a -> RequesterT t request response m a # | |
(Monoid a, Monad m) => Monoid (RequesterT t request response m a) Source # | |
Defined in Reflex.Requester.Base mempty :: RequesterT t request response m a # mappend :: RequesterT t request response m a -> RequesterT t request response m a -> RequesterT t request response m a # mconcat :: [RequesterT t request response m a] -> RequesterT t request response m a # | |
type PrimState (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base | |
type Ref (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base | |
type Request (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base | |
type Response (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base | |
type Performable (RequesterT t request response m) Source # | |
Defined in Reflex.Requester.Base |
runRequesterT :: (Reflex t, Monad m) => RequesterT t request response m a -> Event t (RequesterData response) -> m (a, Event t (RequesterData request)) Source #
Run a RequesterT
action. The resulting Event
will fire whenever
requests are made, and responses should be provided in the input Event
.
The Tag
keys will be used to return the responses to the same place the
requests were issued.
:: (Reflex t, MonadFix m) | |
=> (forall x. req x -> req' x) | The function to map over the request |
-> (forall x. rsp' x -> rsp x) | The function to map over the response |
-> RequesterT t req rsp m a | The internal |
-> RequesterT t req' rsp' m a | The resulting |
Map a function over the request and response of a RequesterT
runWithReplaceRequesterTWith :: forall m t request response a b. (Reflex t, MonadHold t m, MonadFix m) => (forall a' b'. m a' -> Event t (m b') -> RequesterT t request response m (a', Event t b')) -> RequesterT t request response m a -> Event t (RequesterT t request response m b) -> RequesterT t request response m (a, Event t b) Source #
traverseIntMapWithKeyWithAdjustRequesterTWith :: forall t request response m v v' p. (Reflex t, MonadHold t m, PatchTarget (p (Event t (IntMap (RequesterData request)))) ~ IntMap (Event t (IntMap (RequesterData request))), Patch (p (Event t (IntMap (RequesterData request)))), Functor p, MonadFix m) => ((Key -> (Key, v) -> m (Event t (IntMap (RequesterData request)), v')) -> IntMap (Key, v) -> Event t (p (Key, v)) -> RequesterT t request response m (IntMap (Event t (IntMap (RequesterData request)), v'), Event t (p (Event t (IntMap (RequesterData request)), v')))) -> (p (Event t (IntMap (RequesterData request))) -> IntMap (Event t (IntMap (RequesterData request)))) -> (Incremental t (p (Event t (IntMap (RequesterData request)))) -> Event t (IntMap (IntMap (RequesterData request)))) -> (Key -> v -> RequesterT t request response m v') -> IntMap v -> Event t (p v) -> RequesterT t request response m (IntMap v', Event t (p v')) Source #
traverseDMapWithKeyWithAdjustRequesterTWith :: forall k t request response m v v' p p'. (GCompare k, Reflex t, MonadHold t m, PatchTarget (p' (Some k) (Event t (IntMap (RequesterData request)))) ~ Map (Some k) (Event t (IntMap (RequesterData request))), Patch (p' (Some k) (Event t (IntMap (RequesterData request)))), MonadFix m) => (forall k' v1 v2. GCompare k' => (forall a. k' a -> v1 a -> m (v2 a)) -> DMap k' v1 -> Event t (p k' v1) -> RequesterT t request response m (DMap k' v2, Event t (p k' v2))) -> (forall v1 v2. (forall a. v1 a -> v2 a) -> p k v1 -> p k v2) -> (forall v1 v2. (forall a. v1 a -> v2) -> p k v1 -> p' (Some k) v2) -> (forall v2. p' (Some k) v2 -> Map (Some k) v2) -> (forall a. Incremental t (p' (Some k) (Event t a)) -> Event t (Map (Some k) a)) -> (forall a. k a -> v a -> RequesterT t request response m (v' a)) -> DMap k v -> Event t (p k v) -> RequesterT t request response m (DMap k v', Event t (p k v')) Source #
data RequesterData f Source #
data RequesterDataKey a Source #
traverseRequesterData :: forall m request response. Applicative m => (forall a. request a -> m (response a)) -> RequesterData request -> m (RequesterData response) Source #
Runs in reverse to accommodate for the fact that we accumulate it in reverse
forRequesterData :: forall request response m. Applicative m => RequesterData request -> (forall a. request a -> m (response a)) -> m (RequesterData response) Source #
traverseRequesterData
with its arguments flipped
requesterDataToList :: RequesterData f -> [DSum RequesterDataKey f] Source #
singletonRequesterData :: RequesterDataKey a -> f a -> RequesterData f Source #
matchResponsesWithRequests Source #
:: (MonadFix m, MonadHold t m, Reflex t) | |
=> (forall a. request a -> (rawRequest, rawResponse -> response a)) | Given a request (from |
-> Event t (RequesterData request) | The outgoing requests |
-> Event t (Int, rawResponse) | The incoming responses, tagged by an identifying key |
-> m (Event t (Map Int rawRequest), Event t (RequesterData response)) | A map of outgoing wire-format requests and an event of responses keyed
by the |
Matches incoming responses with previously-sent requests and uses the provided request "decoder" function to process incoming responses.
multiEntry :: IntMap (RequesterData f) -> Entry f Multi Source #
unMultiEntry :: Entry f Multi -> IntMap (RequesterData f) Source #
requesting' :: (MyTagTypeOffset x, Monad m) => Event t (Entry request x) -> RequesterT t request response m (Event t (Entry response x)) Source #