reflex-0.9.0.0: Higher-order Functional Reactive Programming
Safe HaskellSafe-Inferred
LanguageHaskell2010

Reflex.Requester.Base.Internal

Description

This module provides RequesterT, the standard implementation of Requester.

Synopsis

Documentation

newtype TagMap (f :: Type -> Type) Source #

Constructors

TagMap (IntMap Any) 

newtype RequesterData f Source #

Constructors

RequesterData (TagMap (Entry f)) 

mergeTagMap :: forall f. TagMap (Entry f) -> TagMap (Entry f) -> TagMap (Entry f) Source #

singletonTagMap :: forall f a. MyTag a -> f a -> TagMap f Source #

tagMapToList :: forall f. TagMap f -> [DSum MyTag f] Source #

traverseTagMapWithKey :: forall t f g. Applicative t => (forall a. MyTag a -> f a -> t (g a)) -> TagMap f -> t (TagMap g) 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

data Single a Source #

Instances

Instances details
MyTagTypeOffset (Single a) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy (Single a) -> Int Source #

data Multi Source #

Instances

Instances details
MyTagTypeOffset Multi Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy Multi -> Int Source #

data Multi2 (k :: Type -> Type) Source #

Instances

Instances details
MyTagTypeOffset (Multi2 k) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy (Multi2 k) -> Int Source #

data Multi3 Source #

Instances

Instances details
MyTagTypeOffset Multi3 Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy Multi3 -> Int Source #

class MyTagTypeOffset x where Source #

Methods

myTagTypeOffset :: proxy x -> Int Source #

Instances

Instances details
MyTagTypeOffset Multi Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy Multi -> Int Source #

MyTagTypeOffset Multi3 Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy Multi3 -> Int Source #

MyTagTypeOffset (Multi2 k) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy (Multi2 k) -> Int Source #

MyTagTypeOffset (Single a) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

myTagTypeOffset :: proxy (Single a) -> Int Source #

type family EntryContents request a where ... Source #

Equations

EntryContents request (Single a) = request a 
EntryContents request Multi = IntMap (RequesterData request) 
EntryContents request (Multi2 k) = Multi2Contents k request 
EntryContents request Multi3 = IntMap (IntMap (RequesterData request)) 

data Multi2Contents k request Source #

newtype Entry request x Source #

Constructors

Entry 

Fields

singleEntry :: f a -> Entry f (Single a) Source #

newtype MyTag x Source #

We use a hack here to pretend we have x ~ request a; we don't want to use a GADT, because GADTs (even with zero-size existential contexts) can't be newtypes WARNING: This type should never be exposed. In particular, this is extremely unsound if a MyTag from one run of runRequesterT is ever compared against a MyTag from another

Constructors

MyTag Int 

Instances

Instances details
GCompare MyTag Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

gcompare :: forall (a :: k) (b :: k). MyTag a -> MyTag b -> GOrdering a b #

GEq MyTag Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

geq :: forall (a :: k) (b :: k). MyTag a -> MyTag b -> Maybe (a :~: b) #

Enum (MyTag x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

succ :: MyTag x -> MyTag x #

pred :: MyTag x -> MyTag x #

toEnum :: Int -> MyTag x #

fromEnum :: MyTag x -> Int #

enumFrom :: MyTag x -> [MyTag x] #

enumFromThen :: MyTag x -> MyTag x -> [MyTag x] #

enumFromTo :: MyTag x -> MyTag x -> [MyTag x] #

enumFromThenTo :: MyTag x -> MyTag x -> MyTag x -> [MyTag x] #

Show (MyTag x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

showsPrec :: Int -> MyTag x -> ShowS #

show :: MyTag x -> String #

showList :: [MyTag x] -> ShowS #

Eq (MyTag x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

(==) :: MyTag x -> MyTag x -> Bool #

(/=) :: MyTag x -> MyTag x -> Bool #

Ord (MyTag x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

compare :: MyTag x -> MyTag x -> Ordering #

(<) :: MyTag x -> MyTag x -> Bool #

(<=) :: MyTag x -> MyTag x -> Bool #

(>) :: MyTag x -> MyTag x -> Bool #

(>=) :: MyTag x -> MyTag x -> Bool #

max :: MyTag x -> MyTag x -> MyTag x #

min :: MyTag x -> MyTag x -> MyTag x #

newtype MyTagWrap (f :: Type -> Type) x Source #

Constructors

MyTagWrap Int 

Instances

Instances details
GCompare (MyTagWrap f :: Type -> Type) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

gcompare :: forall (a :: k) (b :: k). MyTagWrap f a -> MyTagWrap f b -> GOrdering a b #

GEq (MyTagWrap f :: Type -> Type) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

geq :: forall (a :: k) (b :: k). MyTagWrap f a -> MyTagWrap f b -> Maybe (a :~: b) #

Enum (MyTagWrap f x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

succ :: MyTagWrap f x -> MyTagWrap f x #

pred :: MyTagWrap f x -> MyTagWrap f x #

toEnum :: Int -> MyTagWrap f x #

fromEnum :: MyTagWrap f x -> Int #

enumFrom :: MyTagWrap f x -> [MyTagWrap f x] #

enumFromThen :: MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x] #

enumFromTo :: MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x] #

enumFromThenTo :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x] #

Show (MyTagWrap f x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

showsPrec :: Int -> MyTagWrap f x -> ShowS #

show :: MyTagWrap f x -> String #

showList :: [MyTagWrap f x] -> ShowS #

Eq (MyTagWrap f x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

(==) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

(/=) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

Ord (MyTagWrap f x) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

compare :: MyTagWrap f x -> MyTagWrap f x -> Ordering #

(<) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

(<=) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

(>) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

(>=) :: MyTagWrap f x -> MyTagWrap f x -> Bool #

max :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x #

min :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x #

newtype RequesterT t request (response :: Type -> Type) m a Source #

A basic implementation of Requester.

Constructors

RequesterT 

Instances

Instances details
MonadHold t m => MonadHold (t :: Type) (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

now :: RequesterT t request response m (Event t ()) Source #

MonadSample t m => MonadSample (t :: Type) (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

sample :: Behavior t a -> RequesterT t request response m a Source #

EventWriter t w m => EventWriter t w (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

tellEvent :: Event t w -> RequesterT t request response m () Source #

MFunctor (RequesterT t request response :: (Type -> Type) -> Type -> Type) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

hoist :: forall m n (b :: k). Monad m => (forall a. m a -> n a) -> RequesterT t request response m b -> RequesterT t request response n b #

MonadReader r m => MonadReader r (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

(Reflex t, Adjustable t m, MonadHold t m, MonadFix m) => Adjustable t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

NotReady t m => NotReady t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.NotReady.Class

Methods

notReadyUntil :: Event t a -> RequesterT t request response m () Source #

notReady :: RequesterT t request response m () Source #

PerformEvent t m => PerformEvent t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Associated Types

type Performable (RequesterT t request response m) :: Type -> Type Source #

Methods

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 #

PostBuild t m => PostBuild t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

getPostBuild :: RequesterT t request response m (Event t ()) Source #

(Reflex t, Monad m) => Requester t (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Associated Types

type Request (RequesterT t request response m) :: Type -> Type Source #

type Response (RequesterT t request response m) :: Type -> Type Source #

Methods

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 # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

MonadTrans (RequesterT t request response) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

lift :: Monad m => m a -> RequesterT t request response m a #

MonadFix m => MonadFix (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

mfix :: (a -> RequesterT t request response m a) -> RequesterT t request response m a #

MonadIO m => MonadIO (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

liftIO :: IO a -> RequesterT t request response m a #

Monad m => Applicative (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

Functor m => Functor (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

Monad m => Monad (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

(>>=) :: 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 #

MonadAsyncException m => MonadAsyncException (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

MonadException m => MonadException (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

PrimMonad m => PrimMonad (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Associated Types

type PrimState (RequesterT t request response m) #

Methods

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 # 
Instance details

Defined in Reflex.Requester.Base.Internal

Associated Types

type Ref (RequesterT t request response m) :: Type -> Type #

Methods

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 () #

(Monoid a, Monad m) => Monoid (RequesterT t request response m a) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

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 #

(Semigroup a, Monad m) => Semigroup (RequesterT t request response m a) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

Methods

(<>) :: 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 #

type PrimState (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

type PrimState (RequesterT t request response m) = PrimState m
type Ref (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

type Ref (RequesterT t request response m) = Ref m
type Performable (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

type Performable (RequesterT t request response m) = Performable m
type Request (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

type Request (RequesterT t request response m) = request
type Response (RequesterT t request response m) Source # 
Instance details

Defined in Reflex.Requester.Base.Internal

type Response (RequesterT t request response m) = response

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.

withRequesterT Source #

Arguments

:: (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 whose input and output will be transformed

-> RequesterT t req' rsp' m a

The resulting RequesterT

Map a function over the request and response of a RequesterT

tagRequest :: forall m x t request response. (Monad m, MyTagTypeOffset x) => Event t (Entry request x) -> RequesterT t request response m (MyTagWrap request (Entry request x)) Source #

responseFromTag :: forall m t request response x. Monad m => MyTagWrap response (Entry response x) -> RequesterT t request response m (Event t (Entry response x)) Source #

requesting' :: (MyTagTypeOffset x, Monad m) => Event t (Entry request x) -> RequesterT t request response m (Event t (Entry response x)) Source #

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 Decoder rawResponse response Source #

Constructors

forall a. Decoder (RequesterDataKey a) (rawResponse -> response a) 

matchResponsesWithRequests Source #

Arguments

:: forall t rawRequest rawResponse request response m. (MonadFix m, MonadHold t m, Reflex t) 
=> (forall a. request a -> (rawRequest, rawResponse -> response a))

Given a request (from Requester), produces the wire format of the request and a function used to process the associated response

-> 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 RequesterData key of the associated outgoing request

matchResponseMapWithRequests Source #

Arguments

:: forall t rawRequest rawResponse request response m. (MonadFix m, MonadHold t m, Reflex t) 
=> (forall a. request a -> (rawRequest, rawResponse -> response a))

Given a request (from Requester), produces the wire format of the request and a function used to process the associated response

-> Event t (RequesterData request)

The outgoing requests

-> Event t (Map Int rawResponse)

A map of 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 RequesterData key of the associated outgoing request

Matches incoming responses with previously-sent requests and uses the provided request "decoder" function to process incoming responses.