{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE EmptyDataDecls #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE RecursiveDo #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UndecidableInstances #-}
#ifdef USE_REFLEX_OPTIMIZER
{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
#endif
module Reflex.Requester.Base.Internal where
import Reflex.Class
import Reflex.Adjustable.Class
import Reflex.Dynamic
import Reflex.EventWriter.Class
import Reflex.Host.Class
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.Requester.Class
import Reflex.TriggerEvent.Class
import Control.Applicative (liftA2)
import Control.Monad.Exception
import Control.Monad.Identity
import Control.Monad.Morph
import Control.Monad.Primitive
import Control.Monad.Reader
import Control.Monad.Ref
import Control.Monad.State.Strict
import Data.Bits
import Data.Coerce
import Data.Constraint
import Data.Dependent.Map (DMap)
import qualified Data.Dependent.Map as DMap
import Data.Dependent.Sum (DSum (..))
import Data.Functor.Compose
import Data.Functor.Misc
import Data.IntMap.Strict (IntMap)
import qualified Data.IntMap.Strict as IntMap
import Data.Kind (Type)
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Monoid ((<>))
import Data.Proxy
import qualified Data.Semigroup as S
import Data.Some (Some(Some))
import Data.Type.Equality
import Data.Unique.Tag
import GHC.Exts (Any)
import Unsafe.Coerce
newtype TagMap (f :: Type -> Type) = TagMap (IntMap Any)
newtype RequesterData f = RequesterData (TagMap (Entry f))
emptyRequesterData :: RequesterData f
emptyRequesterData :: forall (f :: * -> *). RequesterData f
emptyRequesterData = TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ IntMap Any -> TagMap (Entry f)
forall (f :: * -> *). IntMap Any -> TagMap f
TagMap IntMap Any
forall a. IntMap a
IntMap.empty
data RequesterDataKey a where
RequesterDataKey_Single :: {-# UNPACK #-} !(MyTag (Single a)) -> RequesterDataKey a
RequesterDataKey_Multi :: {-# UNPACK #-} !(MyTag Multi) -> {-# UNPACK #-} !Int -> !(RequesterDataKey a) -> RequesterDataKey a
RequesterDataKey_Multi2 :: GCompare k => {-# UNPACK #-} !(MyTag (Multi2 k)) -> !(Some k) -> {-# UNPACK #-} !Int -> !(RequesterDataKey a) -> RequesterDataKey a
RequesterDataKey_Multi3 :: {-# UNPACK #-} !(MyTag Multi3) -> {-# UNPACK #-} !Int -> {-# UNPACK #-} !Int -> !(RequesterDataKey a) -> RequesterDataKey a
singletonRequesterData :: RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData :: forall a (f :: * -> *).
RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData RequesterDataKey a
rdk f a
v = case RequesterDataKey a
rdk of
RequesterDataKey_Single MyTag (Single a)
k -> TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ MyTag (Single a) -> Entry f (Single a) -> TagMap (Entry f)
forall (f :: * -> *) a. MyTag a -> f a -> TagMap f
singletonTagMap MyTag (Single a)
k (Entry f (Single a) -> TagMap (Entry f))
-> Entry f (Single a) -> TagMap (Entry f)
forall a b. (a -> b) -> a -> b
$ EntryContents f (Single a) -> Entry f (Single a)
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry f a
EntryContents f (Single a)
v
RequesterDataKey_Multi MyTag Multi
k Int
k' RequesterDataKey a
k'' -> TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ MyTag Multi -> Entry f Multi -> TagMap (Entry f)
forall (f :: * -> *) a. MyTag a -> f a -> TagMap f
singletonTagMap MyTag Multi
k (Entry f Multi -> TagMap (Entry f))
-> Entry f Multi -> TagMap (Entry f)
forall a b. (a -> b) -> a -> b
$ EntryContents f Multi -> Entry f Multi
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents f Multi -> Entry f Multi)
-> EntryContents f Multi -> Entry f Multi
forall a b. (a -> b) -> a -> b
$ Int -> RequesterData f -> IntMap (RequesterData f)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
k' (RequesterData f -> IntMap (RequesterData f))
-> RequesterData f -> IntMap (RequesterData f)
forall a b. (a -> b) -> a -> b
$ RequesterDataKey a -> f a -> RequesterData f
forall a (f :: * -> *).
RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData RequesterDataKey a
k'' f a
v
RequesterDataKey_Multi2 MyTag (Multi2 k)
k Some k
k' Int
k'' RequesterDataKey a
k''' -> TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ MyTag (Multi2 k) -> Entry f (Multi2 k) -> TagMap (Entry f)
forall (f :: * -> *) a. MyTag a -> f a -> TagMap f
singletonTagMap MyTag (Multi2 k)
k (Entry f (Multi2 k) -> TagMap (Entry f))
-> Entry f (Multi2 k) -> TagMap (Entry f)
forall a b. (a -> b) -> a -> b
$ EntryContents f (Multi2 k) -> Entry f (Multi2 k)
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents f (Multi2 k) -> Entry f (Multi2 k))
-> EntryContents f (Multi2 k) -> Entry f (Multi2 k)
forall a b. (a -> b) -> a -> b
$ Multi2Contents
{ _multi2Contents_values :: Map (Some k) (IntMap (RequesterData f))
_multi2Contents_values = Some k
-> IntMap (RequesterData f)
-> Map (Some k) (IntMap (RequesterData f))
forall k a. k -> a -> Map k a
Map.singleton Some k
k' (IntMap (RequesterData f)
-> Map (Some k) (IntMap (RequesterData f)))
-> IntMap (RequesterData f)
-> Map (Some k) (IntMap (RequesterData f))
forall a b. (a -> b) -> a -> b
$ Int -> RequesterData f -> IntMap (RequesterData f)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
k'' (RequesterData f -> IntMap (RequesterData f))
-> RequesterData f -> IntMap (RequesterData f)
forall a b. (a -> b) -> a -> b
$ RequesterDataKey a -> f a -> RequesterData f
forall a (f :: * -> *).
RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData RequesterDataKey a
k''' f a
v
, _multi2Contents_dict :: Dict (GCompare k)
_multi2Contents_dict = Dict (GCompare k)
forall (a :: Constraint). a => Dict a
Dict
}
RequesterDataKey_Multi3 MyTag Multi3
k Int
k' Int
k'' RequesterDataKey a
k''' -> TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ MyTag Multi3 -> Entry f Multi3 -> TagMap (Entry f)
forall (f :: * -> *) a. MyTag a -> f a -> TagMap f
singletonTagMap MyTag Multi3
k (Entry f Multi3 -> TagMap (Entry f))
-> Entry f Multi3 -> TagMap (Entry f)
forall a b. (a -> b) -> a -> b
$ EntryContents f Multi3 -> Entry f Multi3
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents f Multi3 -> Entry f Multi3)
-> EntryContents f Multi3 -> Entry f Multi3
forall a b. (a -> b) -> a -> b
$ Int
-> IntMap (RequesterData f) -> IntMap (IntMap (RequesterData f))
forall a. Int -> a -> IntMap a
IntMap.singleton Int
k' (IntMap (RequesterData f) -> IntMap (IntMap (RequesterData f)))
-> IntMap (RequesterData f) -> IntMap (IntMap (RequesterData f))
forall a b. (a -> b) -> a -> b
$ Int -> RequesterData f -> IntMap (RequesterData f)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
k'' (RequesterData f -> IntMap (RequesterData f))
-> RequesterData f -> IntMap (RequesterData f)
forall a b. (a -> b) -> a -> b
$ RequesterDataKey a -> f a -> RequesterData f
forall a (f :: * -> *).
RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData RequesterDataKey a
k''' f a
v
mergeRequesterData :: RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData :: forall (f :: * -> *).
RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData (RequesterData TagMap (Entry f)
a) (RequesterData TagMap (Entry f)
b) = TagMap (Entry f) -> RequesterData f
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry f) -> RequesterData f)
-> TagMap (Entry f) -> RequesterData f
forall a b. (a -> b) -> a -> b
$ TagMap (Entry f) -> TagMap (Entry f) -> TagMap (Entry f)
forall (f :: * -> *).
TagMap (Entry f) -> TagMap (Entry f) -> TagMap (Entry f)
mergeTagMap TagMap (Entry f)
a TagMap (Entry f)
b
mergeTagMap :: forall f. TagMap (Entry f) -> TagMap (Entry f) -> TagMap (Entry f)
mergeTagMap :: forall (f :: * -> *).
TagMap (Entry f) -> TagMap (Entry f) -> TagMap (Entry f)
mergeTagMap (TagMap IntMap Any
m) (TagMap IntMap Any
n) =
IntMap Any -> TagMap (Entry f)
forall (f :: * -> *). IntMap Any -> TagMap f
TagMap (IntMap Any -> TagMap (Entry f)) -> IntMap Any -> TagMap (Entry f)
forall a b. (a -> b) -> a -> b
$ (Int -> Any -> Any -> Any)
-> IntMap Any -> IntMap Any -> IntMap Any
forall a. (Int -> a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWithKey ((forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a)
-> Int -> Any -> Any -> Any
g' MyTag a -> Entry f a -> Entry f a -> Entry f a
forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a
combiner) IntMap Any
m IntMap Any
n
where
combiner :: forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a
combiner :: forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a
combiner MyTag a
k (Entry EntryContents f a
a) (Entry EntryContents f a
b) = EntryContents f a -> Entry f a
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents f a -> Entry f a) -> EntryContents f a -> Entry f a
forall a b. (a -> b) -> a -> b
$ case MyTag a -> MyTagType a
forall x. MyTag x -> MyTagType x
myKeyType MyTag a
k of
MyTagType a
MyTagType_Single -> EntryContents f a
a
MyTagType a
MyTagType_Multi -> (RequesterData f -> RequesterData f -> RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith RequesterData f -> RequesterData f -> RequesterData f
forall (f :: * -> *).
RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData IntMap (RequesterData f)
EntryContents f a
a IntMap (RequesterData f)
EntryContents f a
b
MyTagType a
MyTagType_Multi2 -> case Multi2Contents k f -> Dict (GCompare k)
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request -> Dict (GCompare k)
_multi2Contents_dict Multi2Contents k f
EntryContents f a
a of
Dict (GCompare k)
Dict -> Multi2Contents
{ _multi2Contents_values :: Map (Some k) (IntMap (RequesterData f))
_multi2Contents_values = (IntMap (RequesterData f)
-> IntMap (RequesterData f) -> IntMap (RequesterData f))
-> Map (Some k) (IntMap (RequesterData f))
-> Map (Some k) (IntMap (RequesterData f))
-> Map (Some k) (IntMap (RequesterData f))
forall k a. Ord k => (a -> a -> a) -> Map k a -> Map k a -> Map k a
Map.unionWith ((RequesterData f -> RequesterData f -> RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith RequesterData f -> RequesterData f -> RequesterData f
forall (f :: * -> *).
RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData) (Multi2Contents k f -> Map (Some k) (IntMap (RequesterData f))
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values Multi2Contents k f
EntryContents f a
a) (Multi2Contents k f -> Map (Some k) (IntMap (RequesterData f))
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values Multi2Contents k f
EntryContents f a
b)
, _multi2Contents_dict :: Dict (GCompare k)
_multi2Contents_dict = Dict (GCompare k)
forall (a :: Constraint). a => Dict a
Dict
}
MyTagType a
MyTagType_Multi3 -> (IntMap (RequesterData f)
-> IntMap (RequesterData f) -> IntMap (RequesterData f))
-> IntMap (IntMap (RequesterData f))
-> IntMap (IntMap (RequesterData f))
-> IntMap (IntMap (RequesterData f))
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith ((RequesterData f -> RequesterData f -> RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
-> IntMap (RequesterData f)
forall a. (a -> a -> a) -> IntMap a -> IntMap a -> IntMap a
IntMap.unionWith RequesterData f -> RequesterData f -> RequesterData f
forall (f :: * -> *).
RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData) IntMap (IntMap (RequesterData f))
EntryContents f a
a IntMap (IntMap (RequesterData f))
EntryContents f a
b
g' :: (forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a) -> Int -> Any -> Any -> Any
g' :: (forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a)
-> Int -> Any -> Any -> Any
g' forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a
f Int
rawKey Any
a Any
b =
let k :: MyTag Any
k = Int -> MyTag a
forall x. Int -> MyTag x
MyTag Int
rawKey :: MyTag a
fromAny :: Any -> Entry f a
fromAny :: forall a. Any -> Entry f a
fromAny = Any -> Entry f a
forall a b. a -> b
unsafeCoerce
toAny :: Entry f a -> Any
toAny :: forall a. Entry f a -> Any
toAny = Entry f a -> Any
forall a b. a -> b
unsafeCoerce
in Entry f Any -> Any
forall a. Entry f a -> Any
toAny (Entry f Any -> Any) -> Entry f Any -> Any
forall a b. (a -> b) -> a -> b
$ MyTag Any -> Entry f Any -> Entry f Any -> Entry f Any
forall a. MyTag a -> Entry f a -> Entry f a -> Entry f a
f MyTag Any
k (Any -> Entry f Any
forall a. Any -> Entry f a
fromAny Any
a) (Any -> Entry f Any
forall a. Any -> Entry f a
fromAny Any
b)
requesterDataToList :: RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList :: forall (f :: * -> *). RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList (RequesterData TagMap (Entry f)
m) = do
MyTag a
k :=> Entry EntryContents f a
e <- TagMap (Entry f) -> [DSum MyTag (Entry f)]
forall (f :: * -> *). TagMap f -> [DSum MyTag f]
tagMapToList TagMap (Entry f)
m
case MyTag a -> MyTagType a
forall x. MyTag x -> MyTagType x
myKeyType MyTag a
k of
MyTagType a
MyTagType_Single -> DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (DSum RequesterDataKey f -> [DSum RequesterDataKey f])
-> DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a b. (a -> b) -> a -> b
$ MyTag (Single a) -> RequesterDataKey a
forall a. MyTag (Single a) -> RequesterDataKey a
RequesterDataKey_Single MyTag a
MyTag (Single a)
k RequesterDataKey a -> f a -> DSum RequesterDataKey f
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> f a
EntryContents f a
e
MyTagType a
MyTagType_Multi -> do
(Int
k', RequesterData f
e') <- IntMap (RequesterData f) -> [(Int, RequesterData f)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList IntMap (RequesterData f)
EntryContents f a
e
RequesterDataKey a
k'' :=> f a
e'' <- RequesterData f -> [DSum RequesterDataKey f]
forall (f :: * -> *). RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList RequesterData f
e'
DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (DSum RequesterDataKey f -> [DSum RequesterDataKey f])
-> DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a b. (a -> b) -> a -> b
$ MyTag Multi -> Int -> RequesterDataKey a -> RequesterDataKey a
forall a.
MyTag Multi -> Int -> RequesterDataKey a -> RequesterDataKey a
RequesterDataKey_Multi MyTag a
MyTag Multi
k Int
k' RequesterDataKey a
k'' RequesterDataKey a -> f a -> DSum RequesterDataKey f
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> f a
e''
MyTagType a
MyTagType_Multi2 -> case Multi2Contents k f -> Dict (GCompare k)
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request -> Dict (GCompare k)
_multi2Contents_dict Multi2Contents k f
EntryContents f a
e of
Dict (GCompare k)
Dict -> do
(Some k
k', IntMap (RequesterData f)
e') <- Map (Some k) (IntMap (RequesterData f))
-> [(Some k, IntMap (RequesterData f))]
forall k a. Map k a -> [(k, a)]
Map.toList (Map (Some k) (IntMap (RequesterData f))
-> [(Some k, IntMap (RequesterData f))])
-> Map (Some k) (IntMap (RequesterData f))
-> [(Some k, IntMap (RequesterData f))]
forall a b. (a -> b) -> a -> b
$ Multi2Contents k f -> Map (Some k) (IntMap (RequesterData f))
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values Multi2Contents k f
EntryContents f a
e
(Int
k'', RequesterData f
e'') <- IntMap (RequesterData f) -> [(Int, RequesterData f)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList IntMap (RequesterData f)
e'
RequesterDataKey a
k''' :=> f a
e''' <- RequesterData f -> [DSum RequesterDataKey f]
forall (f :: * -> *). RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList RequesterData f
e''
DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (DSum RequesterDataKey f -> [DSum RequesterDataKey f])
-> DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a b. (a -> b) -> a -> b
$ MyTag (Multi2 k)
-> Some k -> Int -> RequesterDataKey a -> RequesterDataKey a
forall (k :: * -> *) a.
GCompare k =>
MyTag (Multi2 k)
-> Some k -> Int -> RequesterDataKey a -> RequesterDataKey a
RequesterDataKey_Multi2 MyTag a
MyTag (Multi2 k)
k Some k
k' Int
k'' RequesterDataKey a
k''' RequesterDataKey a -> f a -> DSum RequesterDataKey f
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> f a
e'''
MyTagType a
MyTagType_Multi3 -> do
(Int
k', IntMap (RequesterData f)
e') <- IntMap (IntMap (RequesterData f))
-> [(Int, IntMap (RequesterData f))]
forall a. IntMap a -> [(Int, a)]
IntMap.toList IntMap (IntMap (RequesterData f))
EntryContents f a
e
(Int
k'', RequesterData f
e'') <- IntMap (RequesterData f) -> [(Int, RequesterData f)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList IntMap (RequesterData f)
e'
RequesterDataKey a
k''' :=> f a
e''' <- RequesterData f -> [DSum RequesterDataKey f]
forall (f :: * -> *). RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList RequesterData f
e''
DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a. a -> [a]
forall (m :: * -> *) a. Monad m => a -> m a
return (DSum RequesterDataKey f -> [DSum RequesterDataKey f])
-> DSum RequesterDataKey f -> [DSum RequesterDataKey f]
forall a b. (a -> b) -> a -> b
$ MyTag Multi3
-> Int -> Int -> RequesterDataKey a -> RequesterDataKey a
forall a.
MyTag Multi3
-> Int -> Int -> RequesterDataKey a -> RequesterDataKey a
RequesterDataKey_Multi3 MyTag a
MyTag Multi3
k Int
k' Int
k'' RequesterDataKey a
k''' RequesterDataKey a -> f a -> DSum RequesterDataKey f
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> f a
e'''
singletonTagMap :: forall f a. MyTag a -> f a -> TagMap f
singletonTagMap :: forall (f :: * -> *) a. MyTag a -> f a -> TagMap f
singletonTagMap (MyTag Int
k) f a
v = IntMap Any -> TagMap f
forall (f :: * -> *). IntMap Any -> TagMap f
TagMap (IntMap Any -> TagMap f) -> IntMap Any -> TagMap f
forall a b. (a -> b) -> a -> b
$ Int -> Any -> IntMap Any
forall a. Int -> a -> IntMap a
IntMap.singleton Int
k (Any -> IntMap Any) -> Any -> IntMap Any
forall a b. (a -> b) -> a -> b
$ (f a -> Any
forall a b. a -> b
unsafeCoerce :: f a -> Any) f a
v
tagMapToList :: forall f. TagMap f -> [DSum MyTag f]
tagMapToList :: forall (f :: * -> *). TagMap f -> [DSum MyTag f]
tagMapToList (TagMap IntMap Any
m) = (Int, Any) -> DSum MyTag f
f ((Int, Any) -> DSum MyTag f) -> [(Int, Any)] -> [DSum MyTag f]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IntMap Any -> [(Int, Any)]
forall a. IntMap a -> [(Int, a)]
IntMap.toList IntMap Any
m
where f :: (Int, Any) -> DSum MyTag f
f :: (Int, Any) -> DSum MyTag f
f (Int
k, Any
v) = Int -> MyTag Any
forall x. Int -> MyTag x
MyTag Int
k MyTag Any -> f Any -> DSum MyTag f
forall {k} (tag :: k -> *) (f :: k -> *) (a :: k).
tag a -> f a -> DSum tag f
:=> (Any -> f a
forall {a}. Any -> f a
forall a b. a -> b
unsafeCoerce :: Any -> f a) Any
v
traverseTagMapWithKey :: forall t f g. Applicative t => (forall a. MyTag a -> f a -> t (g a)) -> TagMap f -> t (TagMap g)
traverseTagMapWithKey :: forall (t :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative t =>
(forall a. MyTag a -> f a -> t (g a)) -> TagMap f -> t (TagMap g)
traverseTagMapWithKey forall a. MyTag a -> f a -> t (g a)
f (TagMap IntMap Any
m) = IntMap Any -> TagMap g
forall (f :: * -> *). IntMap Any -> TagMap f
TagMap (IntMap Any -> TagMap g) -> t (IntMap Any) -> t (TagMap g)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Int -> Any -> t Any) -> IntMap Any -> t (IntMap Any)
forall (t :: * -> *) a b.
Applicative t =>
(Int -> a -> t b) -> IntMap a -> t (IntMap b)
IntMap.traverseWithKey Int -> Any -> t Any
g IntMap Any
m
where
g :: Int -> Any -> t Any
g :: Int -> Any -> t Any
g Int
k Any
v = (g a -> Any
forall {a}. g a -> Any
forall a b. a -> b
unsafeCoerce :: g a -> Any) (g Any -> Any) -> t (g Any) -> t Any
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> MyTag Any -> f Any -> t (g Any)
forall a. MyTag a -> f a -> t (g a)
f (Int -> MyTag Any
forall x. Int -> MyTag x
MyTag Int
k) ((Any -> f a
forall {a}. Any -> f a
forall a b. a -> b
unsafeCoerce :: Any -> f a) Any
v)
traverseRequesterData :: forall m request response. Applicative m => (forall a. request a -> m (response a)) -> RequesterData request -> m (RequesterData response)
traverseRequesterData :: forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData forall a. request a -> m (response a)
f (RequesterData TagMap (Entry request)
m) = TagMap (Entry response) -> RequesterData response
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry response) -> RequesterData response)
-> m (TagMap (Entry response)) -> m (RequesterData response)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (forall a. MyTag a -> Entry request a -> m (Entry response a))
-> TagMap (Entry request) -> m (TagMap (Entry response))
forall (t :: * -> *) (f :: * -> *) (g :: * -> *).
Applicative t =>
(forall a. MyTag a -> f a -> t (g a)) -> TagMap f -> t (TagMap g)
traverseTagMapWithKey MyTag a -> Entry request a -> m (Entry response a)
forall a. MyTag a -> Entry request a -> m (Entry response a)
go TagMap (Entry request)
m
where go :: forall x. MyTag x -> Entry request x -> m (Entry response x)
go :: forall a. MyTag a -> Entry request a -> m (Entry response a)
go MyTag x
k (Entry EntryContents request x
request) = EntryContents response x -> Entry response x
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents response x -> Entry response x)
-> m (EntryContents response x) -> m (Entry response x)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> case MyTag x -> MyTagType x
forall x. MyTag x -> MyTagType x
myKeyType MyTag x
k of
MyTagType x
MyTagType_Single -> request a -> m (response a)
forall a. request a -> m (response a)
f request a
EntryContents request x
request
MyTagType x
MyTagType_Multi -> (RequesterData request -> m (RequesterData response))
-> IntMap (RequesterData request)
-> m (IntMap (RequesterData response))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IntMap a -> f (IntMap b)
traverse ((forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData request a -> m (response a)
forall a. request a -> m (response a)
f) IntMap (RequesterData request)
EntryContents request x
request
MyTagType x
MyTagType_Multi2 -> case EntryContents request x
request of
Multi2Contents { _multi2Contents_values :: forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values = Map (Some k) (IntMap (RequesterData request))
request', _multi2Contents_dict :: forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request -> Dict (GCompare k)
_multi2Contents_dict = Dict (GCompare k)
Dict } -> do
Map (Some k) (IntMap (RequesterData response))
v <- (IntMap (RequesterData request)
-> m (IntMap (RequesterData response)))
-> Map (Some k) (IntMap (RequesterData request))
-> m (Map (Some k) (IntMap (RequesterData response)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> Map (Some k) a -> f (Map (Some k) b)
traverse ((RequesterData request -> m (RequesterData response))
-> IntMap (RequesterData request)
-> m (IntMap (RequesterData response))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IntMap a -> f (IntMap b)
traverse ((forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData request a -> m (response a)
forall a. request a -> m (response a)
f)) Map (Some k) (IntMap (RequesterData request))
request'
pure $ Multi2Contents
{ _multi2Contents_values :: Map (Some k) (IntMap (RequesterData response))
_multi2Contents_values = Map (Some k) (IntMap (RequesterData response))
v
, _multi2Contents_dict :: Dict (GCompare k)
_multi2Contents_dict = Dict (GCompare k)
forall (a :: Constraint). a => Dict a
Dict
}
MyTagType x
MyTagType_Multi3 -> (IntMap (RequesterData request)
-> m (IntMap (RequesterData response)))
-> IntMap (IntMap (RequesterData request))
-> m (IntMap (IntMap (RequesterData response)))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IntMap a -> f (IntMap b)
traverse ((RequesterData request -> m (RequesterData response))
-> IntMap (RequesterData request)
-> m (IntMap (RequesterData response))
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> IntMap a -> f (IntMap b)
traverse ((forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData request a -> m (response a)
forall a. request a -> m (response a)
f)) IntMap (IntMap (RequesterData request))
EntryContents request x
request
forRequesterData :: forall request response m. Applicative m => RequesterData request -> (forall a. request a -> m (response a)) -> m (RequesterData response)
forRequesterData :: forall (request :: * -> *) (response :: * -> *) (m :: * -> *).
Applicative m =>
RequesterData request
-> (forall a. request a -> m (response a))
-> m (RequesterData response)
forRequesterData RequesterData request
r forall a. request a -> m (response a)
f = (forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData request a -> m (response a)
forall a. request a -> m (response a)
f RequesterData request
r
data MyTagType :: Type -> Type where
MyTagType_Single :: MyTagType (Single a)
MyTagType_Multi :: MyTagType Multi
MyTagType_Multi2 :: MyTagType (Multi2 k)
MyTagType_Multi3 :: MyTagType Multi3
myKeyType :: MyTag x -> MyTagType x
myKeyType :: forall x. MyTag x -> MyTagType x
myKeyType (MyTag Int
k) = case Int
k Int -> Int -> Int
forall a. Bits a => a -> a -> a
.&. Int
0x3 of
Int
0x0 -> MyTagType (Single Any) -> MyTagType x
forall a b. a -> b
unsafeCoerce MyTagType (Single Any)
forall k. MyTagType (Single k)
MyTagType_Single
Int
0x1 -> MyTagType Multi -> MyTagType x
forall a b. a -> b
unsafeCoerce MyTagType Multi
MyTagType_Multi
Int
0x2 -> MyTagType (Multi2 Any) -> MyTagType x
forall a b. a -> b
unsafeCoerce MyTagType (Multi2 Any)
forall (k :: * -> *). MyTagType (Multi2 k)
MyTagType_Multi2
Int
0x3 -> MyTagType Multi3 -> MyTagType x
forall a b. a -> b
unsafeCoerce MyTagType Multi3
MyTagType_Multi3
Int
t -> [Char] -> MyTagType x
forall a. HasCallStack => [Char] -> a
error ([Char] -> MyTagType x) -> [Char] -> MyTagType x
forall a b. (a -> b) -> a -> b
$ [Char]
"Reflex.Requester.Base.myKeyType: no such key type" [Char] -> [Char] -> [Char]
forall a. Semigroup a => a -> a -> a
<> Int -> [Char]
forall a. Show a => a -> [Char]
show Int
t
data Single a
data Multi
data Multi2 (k :: Type -> Type)
data Multi3
class MyTagTypeOffset x where
myTagTypeOffset :: proxy x -> Int
instance MyTagTypeOffset (Single a) where
myTagTypeOffset :: forall (proxy :: * -> *). proxy (Single a) -> Int
myTagTypeOffset proxy (Single a)
_ = Int
0x0
instance MyTagTypeOffset Multi where
myTagTypeOffset :: forall (proxy :: * -> *). proxy Multi -> Int
myTagTypeOffset proxy Multi
_ = Int
0x1
instance MyTagTypeOffset (Multi2 k) where
myTagTypeOffset :: forall (proxy :: * -> *). proxy (Multi2 k) -> Int
myTagTypeOffset proxy (Multi2 k)
_ = Int
0x2
instance MyTagTypeOffset Multi3 where
myTagTypeOffset :: forall (proxy :: * -> *). proxy Multi3 -> Int
myTagTypeOffset proxy Multi3
_ = Int
0x3
type family EntryContents request a where
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 = Multi2Contents
{ forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request -> Dict (GCompare k)
_multi2Contents_dict :: {-# UNPACK #-} !(Dict (GCompare k))
, forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values :: {-# UNPACK #-} !(Map (Some k) (IntMap (RequesterData request)))
}
newtype Entry request x = Entry { forall (request :: * -> *) x.
Entry request x -> EntryContents request x
unEntry :: EntryContents request x }
{-# INLINE singleEntry #-}
singleEntry :: f a -> Entry f (Single a)
singleEntry :: forall (f :: * -> *) a. f a -> Entry f (Single a)
singleEntry = f a -> Entry f (Single a)
EntryContents f (Single a) -> Entry f (Single a)
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry
{-# INLINE multiEntry #-}
multiEntry :: IntMap (RequesterData f) -> Entry f Multi
multiEntry :: forall (f :: * -> *). IntMap (RequesterData f) -> Entry f Multi
multiEntry = IntMap (RequesterData f) -> Entry f Multi
EntryContents f Multi -> Entry f Multi
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry
{-# INLINE unMultiEntry #-}
unMultiEntry :: Entry f Multi -> IntMap (RequesterData f)
unMultiEntry :: forall (f :: * -> *). Entry f Multi -> IntMap (RequesterData f)
unMultiEntry = Entry f Multi -> IntMap (RequesterData f)
Entry f Multi -> EntryContents f Multi
forall (request :: * -> *) x.
Entry request x -> EntryContents request x
unEntry
newtype MyTag x = MyTag Int deriving (Int -> MyTag x -> [Char] -> [Char]
[MyTag x] -> [Char] -> [Char]
MyTag x -> [Char]
(Int -> MyTag x -> [Char] -> [Char])
-> (MyTag x -> [Char])
-> ([MyTag x] -> [Char] -> [Char])
-> Show (MyTag x)
forall x. Int -> MyTag x -> [Char] -> [Char]
forall x. [MyTag x] -> [Char] -> [Char]
forall x. MyTag x -> [Char]
forall a.
(Int -> a -> [Char] -> [Char])
-> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
$cshowsPrec :: forall x. Int -> MyTag x -> [Char] -> [Char]
showsPrec :: Int -> MyTag x -> [Char] -> [Char]
$cshow :: forall x. MyTag x -> [Char]
show :: MyTag x -> [Char]
$cshowList :: forall x. [MyTag x] -> [Char] -> [Char]
showList :: [MyTag x] -> [Char] -> [Char]
Show, MyTag x -> MyTag x -> Bool
(MyTag x -> MyTag x -> Bool)
-> (MyTag x -> MyTag x -> Bool) -> Eq (MyTag x)
forall x. MyTag x -> MyTag x -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall x. MyTag x -> MyTag x -> Bool
== :: MyTag x -> MyTag x -> Bool
$c/= :: forall x. MyTag x -> MyTag x -> Bool
/= :: MyTag x -> MyTag x -> Bool
Eq, Eq (MyTag x)
Eq (MyTag x)
-> (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)
-> (MyTag x -> MyTag x -> MyTag x)
-> (MyTag x -> MyTag x -> MyTag x)
-> Ord (MyTag x)
MyTag x -> MyTag x -> Bool
MyTag x -> MyTag x -> Ordering
MyTag x -> MyTag x -> MyTag x
forall x. Eq (MyTag x)
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall x. MyTag x -> MyTag x -> Bool
forall x. MyTag x -> MyTag x -> Ordering
forall x. MyTag x -> MyTag x -> MyTag x
$ccompare :: forall x. MyTag x -> MyTag x -> Ordering
compare :: MyTag x -> MyTag x -> Ordering
$c< :: forall x. MyTag x -> MyTag x -> Bool
< :: MyTag x -> MyTag x -> Bool
$c<= :: forall x. MyTag x -> MyTag x -> Bool
<= :: MyTag x -> MyTag x -> Bool
$c> :: forall x. MyTag x -> MyTag x -> Bool
> :: MyTag x -> MyTag x -> Bool
$c>= :: forall x. MyTag x -> MyTag x -> Bool
>= :: MyTag x -> MyTag x -> Bool
$cmax :: forall x. MyTag x -> MyTag x -> MyTag x
max :: MyTag x -> MyTag x -> MyTag x
$cmin :: forall x. MyTag x -> MyTag x -> MyTag x
min :: MyTag x -> MyTag x -> MyTag x
Ord, Int -> MyTag x
MyTag x -> Int
MyTag x -> [MyTag x]
MyTag x -> MyTag x
MyTag x -> MyTag x -> [MyTag x]
MyTag x -> MyTag x -> MyTag x -> [MyTag x]
(MyTag x -> MyTag x)
-> (MyTag x -> MyTag x)
-> (Int -> MyTag x)
-> (MyTag x -> Int)
-> (MyTag x -> [MyTag x])
-> (MyTag x -> MyTag x -> [MyTag x])
-> (MyTag x -> MyTag x -> [MyTag x])
-> (MyTag x -> MyTag x -> MyTag x -> [MyTag x])
-> Enum (MyTag x)
forall x. Int -> MyTag x
forall x. MyTag x -> Int
forall x. MyTag x -> [MyTag x]
forall x. MyTag x -> MyTag x
forall x. MyTag x -> MyTag x -> [MyTag x]
forall x. MyTag x -> MyTag x -> MyTag x -> [MyTag x]
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: forall x. MyTag x -> MyTag x
succ :: MyTag x -> MyTag x
$cpred :: forall x. MyTag x -> MyTag x
pred :: MyTag x -> MyTag x
$ctoEnum :: forall x. Int -> MyTag x
toEnum :: Int -> MyTag x
$cfromEnum :: forall x. MyTag x -> Int
fromEnum :: MyTag x -> Int
$cenumFrom :: forall x. MyTag x -> [MyTag x]
enumFrom :: MyTag x -> [MyTag x]
$cenumFromThen :: forall x. MyTag x -> MyTag x -> [MyTag x]
enumFromThen :: MyTag x -> MyTag x -> [MyTag x]
$cenumFromTo :: forall x. MyTag x -> MyTag x -> [MyTag x]
enumFromTo :: MyTag x -> MyTag x -> [MyTag x]
$cenumFromThenTo :: forall x. MyTag x -> MyTag x -> MyTag x -> [MyTag x]
enumFromThenTo :: MyTag x -> MyTag x -> MyTag x -> [MyTag x]
Enum)
newtype MyTagWrap (f :: Type -> Type) x = MyTagWrap Int deriving (Int -> MyTagWrap f x -> [Char] -> [Char]
[MyTagWrap f x] -> [Char] -> [Char]
MyTagWrap f x -> [Char]
(Int -> MyTagWrap f x -> [Char] -> [Char])
-> (MyTagWrap f x -> [Char])
-> ([MyTagWrap f x] -> [Char] -> [Char])
-> Show (MyTagWrap f x)
forall a.
(Int -> a -> [Char] -> [Char])
-> (a -> [Char]) -> ([a] -> [Char] -> [Char]) -> Show a
forall (f :: * -> *) x. Int -> MyTagWrap f x -> [Char] -> [Char]
forall (f :: * -> *) x. [MyTagWrap f x] -> [Char] -> [Char]
forall (f :: * -> *) x. MyTagWrap f x -> [Char]
$cshowsPrec :: forall (f :: * -> *) x. Int -> MyTagWrap f x -> [Char] -> [Char]
showsPrec :: Int -> MyTagWrap f x -> [Char] -> [Char]
$cshow :: forall (f :: * -> *) x. MyTagWrap f x -> [Char]
show :: MyTagWrap f x -> [Char]
$cshowList :: forall (f :: * -> *) x. [MyTagWrap f x] -> [Char] -> [Char]
showList :: [MyTagWrap f x] -> [Char] -> [Char]
Show, MyTagWrap f x -> MyTagWrap f x -> Bool
(MyTagWrap f x -> MyTagWrap f x -> Bool)
-> (MyTagWrap f x -> MyTagWrap f x -> Bool) -> Eq (MyTagWrap f x)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
$c== :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
== :: MyTagWrap f x -> MyTagWrap f x -> Bool
$c/= :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
/= :: MyTagWrap f x -> MyTagWrap f x -> Bool
Eq, Eq (MyTagWrap f x)
Eq (MyTagWrap f x)
-> (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)
-> (MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x)
-> (MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x)
-> Ord (MyTagWrap f x)
MyTagWrap f x -> MyTagWrap f x -> Bool
MyTagWrap f x -> MyTagWrap f x -> Ordering
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall (f :: * -> *) x. Eq (MyTagWrap f x)
forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Ordering
forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
$ccompare :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Ordering
compare :: MyTagWrap f x -> MyTagWrap f x -> Ordering
$c< :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
< :: MyTagWrap f x -> MyTagWrap f x -> Bool
$c<= :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
<= :: MyTagWrap f x -> MyTagWrap f x -> Bool
$c> :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
> :: MyTagWrap f x -> MyTagWrap f x -> Bool
$c>= :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x -> Bool
>= :: MyTagWrap f x -> MyTagWrap f x -> Bool
$cmax :: forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
max :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
$cmin :: forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
min :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x
Ord, Int -> MyTagWrap f x
MyTagWrap f x -> Int
MyTagWrap f x -> [MyTagWrap f x]
MyTagWrap f x -> MyTagWrap f x
MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
(MyTagWrap f x -> MyTagWrap f x)
-> (MyTagWrap f x -> MyTagWrap f x)
-> (Int -> MyTagWrap f x)
-> (MyTagWrap f x -> Int)
-> (MyTagWrap f x -> [MyTagWrap f x])
-> (MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x])
-> (MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x])
-> (MyTagWrap f x
-> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x])
-> Enum (MyTagWrap f x)
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
forall (f :: * -> *) x. Int -> MyTagWrap f x
forall (f :: * -> *) x. MyTagWrap f x -> Int
forall (f :: * -> *) x. MyTagWrap f x -> [MyTagWrap f x]
forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x
forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
$csucc :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x
succ :: MyTagWrap f x -> MyTagWrap f x
$cpred :: forall (f :: * -> *) x. MyTagWrap f x -> MyTagWrap f x
pred :: MyTagWrap f x -> MyTagWrap f x
$ctoEnum :: forall (f :: * -> *) x. Int -> MyTagWrap f x
toEnum :: Int -> MyTagWrap f x
$cfromEnum :: forall (f :: * -> *) x. MyTagWrap f x -> Int
fromEnum :: MyTagWrap f x -> Int
$cenumFrom :: forall (f :: * -> *) x. MyTagWrap f x -> [MyTagWrap f x]
enumFrom :: MyTagWrap f x -> [MyTagWrap f x]
$cenumFromThen :: forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
enumFromThen :: MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
$cenumFromTo :: forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
enumFromTo :: MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
$cenumFromThenTo :: forall (f :: * -> *) x.
MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
enumFromThenTo :: MyTagWrap f x -> MyTagWrap f x -> MyTagWrap f x -> [MyTagWrap f x]
Enum)
{-# INLINE castMyTagWrap #-}
castMyTagWrap :: MyTagWrap f (Entry f x) -> MyTagWrap g (Entry g x)
castMyTagWrap :: forall (f :: * -> *) x (g :: * -> *).
MyTagWrap f (Entry f x) -> MyTagWrap g (Entry g x)
castMyTagWrap = MyTagWrap f (Entry f x) -> MyTagWrap g (Entry g x)
forall a b. Coercible a b => a -> b
coerce
instance GEq MyTag where
(MyTag Int
a) geq :: forall a b. MyTag a -> MyTag b -> Maybe (a :~: b)
`geq` (MyTag Int
b) =
if Int
a Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
b
then (a :~: b) -> Maybe (a :~: b)
forall a. a -> Maybe a
Just ((a :~: b) -> Maybe (a :~: b)) -> (a :~: b) -> Maybe (a :~: b)
forall a b. (a -> b) -> a -> b
$ (Any :~: Any) -> a :~: b
forall a b. a -> b
unsafeCoerce Any :~: Any
forall {k} (a :: k). a :~: a
Refl
else Maybe (a :~: b)
forall a. Maybe a
Nothing
instance GCompare MyTag where
(MyTag Int
a) gcompare :: forall a b. MyTag a -> MyTag b -> GOrdering a b
`gcompare` (MyTag Int
b) =
case Int
a Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
b of
Ordering
LT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
GLT
Ordering
EQ -> GOrdering Any Any -> GOrdering a b
forall a b. a -> b
unsafeCoerce GOrdering Any Any
forall {k} (a :: k). GOrdering a a
GEQ
Ordering
GT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
GGT
instance GEq (MyTagWrap f) where
(MyTagWrap Int
a) geq :: forall a b. MyTagWrap f a -> MyTagWrap f b -> Maybe (a :~: b)
`geq` (MyTagWrap Int
b) =
if Int
a Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== Int
b
then (a :~: b) -> Maybe (a :~: b)
forall a. a -> Maybe a
Just ((a :~: b) -> Maybe (a :~: b)) -> (a :~: b) -> Maybe (a :~: b)
forall a b. (a -> b) -> a -> b
$ (Any :~: Any) -> a :~: b
forall a b. a -> b
unsafeCoerce Any :~: Any
forall {k} (a :: k). a :~: a
Refl
else Maybe (a :~: b)
forall a. Maybe a
Nothing
instance GCompare (MyTagWrap f) where
(MyTagWrap Int
a) gcompare :: forall a b. MyTagWrap f a -> MyTagWrap f b -> GOrdering a b
`gcompare` (MyTagWrap Int
b) =
case Int
a Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
b of
Ordering
LT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
GLT
Ordering
EQ -> GOrdering Any Any -> GOrdering a b
forall a b. a -> b
unsafeCoerce GOrdering Any Any
forall {k} (a :: k). GOrdering a a
GEQ
Ordering
GT -> GOrdering a b
forall {k} (a :: k) (b :: k). GOrdering a b
GGT
data RequesterState t (request :: Type -> Type) = RequesterState
{ forall t (request :: * -> *). RequesterState t request -> Int
_requesterState_nextMyTag :: {-# UNPACK #-} !Int
, forall t (request :: * -> *).
RequesterState t request -> [(Int, Event t Any)]
_requesterState_requests :: ![(Int, Event t Any)]
}
newtype RequesterT t request (response :: Type -> Type) m a = RequesterT { forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
RequesterT t request response m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
unRequesterT :: StateT (RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a }
deriving ((forall a b.
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b)
-> (forall a b.
a
-> RequesterT t request response m b
-> RequesterT t request response m a)
-> Functor (RequesterT t request response m)
forall a b.
a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall a b.
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Functor m =>
a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Functor m =>
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Functor m =>
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
fmap :: forall a b.
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
$c<$ :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Functor m =>
a
-> RequesterT t request response m b
-> RequesterT t request response m a
<$ :: forall a b.
a
-> RequesterT t request response m b
-> RequesterT t request response m a
Functor, Functor (RequesterT t request response m)
Functor (RequesterT t request response m)
-> (forall a. a -> RequesterT t request response m a)
-> (forall a b.
RequesterT t request response m (a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b)
-> (forall a b c.
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c)
-> (forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b)
-> (forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a)
-> Applicative (RequesterT t request response m)
forall a. a -> RequesterT t request response m a
forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
forall a b.
RequesterT t request response m (a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall a b c.
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
Monad m =>
Functor (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
Monad m =>
a -> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m (a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a b
c.
Monad m =>
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
forall (f :: * -> *).
Functor f
-> (forall a. a -> f a)
-> (forall a b. f (a -> b) -> f a -> f b)
-> (forall a b c. (a -> b -> c) -> f a -> f b -> f c)
-> (forall a b. f a -> f b -> f b)
-> (forall a b. f a -> f b -> f a)
-> Applicative f
$cpure :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
Monad m =>
a -> RequesterT t request response m a
pure :: forall a. a -> RequesterT t request response m a
$c<*> :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m (a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
<*> :: forall a b.
RequesterT t request response m (a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
$cliftA2 :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a b
c.
Monad m =>
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
liftA2 :: forall a b c.
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
$c*> :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
*> :: forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
$c<* :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
<* :: forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
Applicative, Applicative (RequesterT t request response m)
Applicative (RequesterT t request response m)
-> (forall a b.
RequesterT t request response m a
-> (a -> RequesterT t request response m b)
-> RequesterT t request response m b)
-> (forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b)
-> (forall a. a -> RequesterT t request response m a)
-> Monad (RequesterT t request response m)
forall a. a -> RequesterT t request response m a
forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
forall a b.
RequesterT t request response m a
-> (a -> RequesterT t request response m b)
-> RequesterT t request response m b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *).
Monad m =>
Applicative (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
Monad m =>
a -> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> (a -> RequesterT t request response m b)
-> RequesterT t request response m b
forall (m :: * -> *).
Applicative m
-> (forall a b. m a -> (a -> m b) -> m b)
-> (forall a b. m a -> m b -> m b)
-> (forall a. a -> m a)
-> Monad m
$c>>= :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> (a -> RequesterT t request response m b)
-> RequesterT t request response m b
>>= :: forall a b.
RequesterT t request response m a
-> (a -> RequesterT t request response m b)
-> RequesterT t request response m b
$c>> :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
Monad m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
>> :: forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m b
$creturn :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
Monad m =>
a -> RequesterT t request response m a
return :: forall a. a -> RequesterT t request response m a
Monad, Monad (RequesterT t request response m)
Monad (RequesterT t request response m)
-> (forall a.
(a -> RequesterT t request response m a)
-> RequesterT t request response m a)
-> MonadFix (RequesterT t request response m)
forall a.
(a -> RequesterT t request response m a)
-> RequesterT t request response m a
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
MonadFix m =>
Monad (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
MonadFix m =>
(a -> RequesterT t request response m a)
-> RequesterT t request response m a
forall (m :: * -> *).
Monad m -> (forall a. (a -> m a) -> m a) -> MonadFix m
$cmfix :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
MonadFix m =>
(a -> RequesterT t request response m a)
-> RequesterT t request response m a
mfix :: forall a.
(a -> RequesterT t request response m a)
-> RequesterT t request response m a
MonadFix, Monad (RequesterT t request response m)
Monad (RequesterT t request response m)
-> (forall a. IO a -> RequesterT t request response m a)
-> MonadIO (RequesterT t request response m)
forall a. IO a -> RequesterT t request response m a
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
MonadIO m =>
Monad (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
MonadIO m =>
IO a -> RequesterT t request response m a
forall (m :: * -> *).
Monad m -> (forall a. IO a -> m a) -> MonadIO m
$cliftIO :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
MonadIO m =>
IO a -> RequesterT t request response m a
liftIO :: forall a. IO a -> RequesterT t request response m a
MonadIO, Monad (RequesterT t request response m)
Monad (RequesterT t request response m)
-> (forall e a.
Exception e =>
e -> RequesterT t request response m a)
-> (forall e a.
Exception e =>
RequesterT t request response m a
-> (e -> RequesterT t request response m a)
-> RequesterT t request response m a)
-> (forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a)
-> MonadException (RequesterT t request response m)
forall e a. Exception e => e -> RequesterT t request response m a
forall e a.
Exception e =>
RequesterT t request response m a
-> (e -> RequesterT t request response m a)
-> RequesterT t request response m a
forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
MonadException m =>
Monad (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) e
a.
(MonadException m, Exception e) =>
e -> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) e
a.
(MonadException m, Exception e) =>
RequesterT t request response m a
-> (e -> RequesterT t request response m a)
-> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
MonadException m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
forall (m :: * -> *).
Monad m
-> (forall e a. Exception e => e -> m a)
-> (forall e a. Exception e => m a -> (e -> m a) -> m a)
-> (forall a b. m a -> m b -> m a)
-> MonadException m
$cthrow :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) e
a.
(MonadException m, Exception e) =>
e -> RequesterT t request response m a
throw :: forall e a. Exception e => e -> RequesterT t request response m a
$ccatch :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) e
a.
(MonadException m, Exception e) =>
RequesterT t request response m a
-> (e -> RequesterT t request response m a)
-> RequesterT t request response m a
catch :: forall e a.
Exception e =>
RequesterT t request response m a
-> (e -> RequesterT t request response m a)
-> RequesterT t request response m a
$cfinally :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a
b.
MonadException m =>
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
finally :: forall a b.
RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m a
MonadException
#if MIN_VERSION_base(4,9,1)
, MonadIO (RequesterT t request response m)
MonadException (RequesterT t request response m)
MonadIO (RequesterT t request response m)
-> MonadException (RequesterT t request response m)
-> (forall b.
((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)
-> MonadAsyncException (RequesterT t request response m)
forall b.
((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
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
MonadAsyncException m =>
MonadIO (RequesterT t request response m)
forall {t} {request :: * -> *} {response :: * -> *} {m :: * -> *}.
MonadAsyncException m =>
MonadException (RequesterT t request response m)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) b.
MonadAsyncException m =>
((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
forall (m :: * -> *).
MonadIO m
-> MonadException m
-> (forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> MonadAsyncException m
$cmask :: forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) b.
MonadAsyncException m =>
((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
mask :: forall b.
((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
MonadAsyncException
#endif
)
deriving instance MonadSample t m => MonadSample t (RequesterT t request response m)
deriving instance MonadHold t m => MonadHold t (RequesterT t request response m)
deriving instance PostBuild t m => PostBuild t (RequesterT t request response m)
deriving instance TriggerEvent t m => TriggerEvent t (RequesterT t request response m)
instance EventWriter t w m => EventWriter t w (RequesterT t request response m) where
tellEvent :: Event t w -> RequesterT t request response m ()
tellEvent = m () -> RequesterT t request response m ()
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RequesterT t request response m ())
-> (Event t w -> m ())
-> Event t w
-> RequesterT t request response m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t w -> m ()
forall t w (m :: * -> *). EventWriter t w m => Event t w -> m ()
tellEvent
instance PrimMonad m => PrimMonad (RequesterT t request response m) where
type PrimState (RequesterT t request response m) = PrimState m
primitive :: forall a.
(State# (PrimState (RequesterT t request response m))
-> (# State# (PrimState (RequesterT t request response m)), a #))
-> RequesterT t request response m a
primitive = m a -> RequesterT t request response m a
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RequesterT t request response m a)
-> ((State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a)
-> (State# (PrimState m) -> (# State# (PrimState m), a #))
-> RequesterT t request response m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
forall a.
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
instance (Monoid a, Monad m) => Monoid (RequesterT t request response m a) where
mempty :: RequesterT t request response m a
mempty = a -> RequesterT t request response m a
forall a. a -> RequesterT t request response m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
forall a. Monoid a => a
mempty
mappend :: RequesterT t request response m a
-> RequesterT t request response m a
-> RequesterT t request response m a
mappend = (a -> a -> a)
-> RequesterT t request response m a
-> RequesterT t request response m a
-> RequesterT t request response m a
forall a b c.
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Monoid a => a -> a -> a
mappend
instance (S.Semigroup a, Monad m) => S.Semigroup (RequesterT t request response m a) where
<> :: RequesterT t request response m a
-> RequesterT t request response m a
-> RequesterT t request response m a
(<>) = (a -> a -> a)
-> RequesterT t request response m a
-> RequesterT t request response m a
-> RequesterT t request response m a
forall a b c.
(a -> b -> c)
-> RequesterT t request response m a
-> RequesterT t request response m b
-> RequesterT t request response m c
forall (f :: * -> *) a b c.
Applicative f =>
(a -> b -> c) -> f a -> f b -> f c
liftA2 a -> a -> a
forall a. Semigroup a => a -> a -> a
(S.<>)
runRequesterT :: (Reflex t, Monad m)
=> RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT :: forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT (RequesterT StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
a) Event t (RequesterData response)
responses = do
(a
result, RequesterState t request
s) <- ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
-> EventSelectorInt t Any -> m (a, RequesterState t request)
forall r (m :: * -> *) a. ReaderT r m a -> r -> m a
runReaderT (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterState t request
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
a (RequesterState t request
-> ReaderT
(EventSelectorInt t Any) m (a, RequesterState t request))
-> RequesterState t request
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
forall a b. (a -> b) -> a -> b
$ Int -> [(Int, Event t Any)] -> RequesterState t request
forall t (request :: * -> *).
Int -> [(Int, Event t Any)] -> RequesterState t request
RequesterState (-Int
4) []) (EventSelectorInt t Any -> m (a, RequesterState t request))
-> EventSelectorInt t Any -> m (a, RequesterState t request)
forall a b. (a -> b) -> a -> b
$ Event t (IntMap Any) -> EventSelectorInt t Any
forall a. Event t (IntMap a) -> EventSelectorInt t a
forall {k} (t :: k) a.
Reflex t =>
Event t (IntMap a) -> EventSelectorInt t a
fanInt (Event t (IntMap Any) -> EventSelectorInt t Any)
-> Event t (IntMap Any) -> EventSelectorInt t Any
forall a b. (a -> b) -> a -> b
$
Event t (RequesterData response) -> Event t (IntMap Any)
forall {k} (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent Event t (RequesterData response)
responses
(a, Event t (RequesterData request))
-> m (a, Event t (RequesterData request))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
result, (IntMap Any -> RequesterData request)
-> Event t (IntMap Any) -> Event t (RequesterData request)
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (TagMap (Entry request) -> RequesterData request
forall (f :: * -> *). TagMap (Entry f) -> RequesterData f
RequesterData (TagMap (Entry request) -> RequesterData request)
-> (IntMap Any -> TagMap (Entry request))
-> IntMap Any
-> RequesterData request
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap Any -> TagMap (Entry request)
forall (f :: * -> *). IntMap Any -> TagMap f
TagMap) (Event t (IntMap Any) -> Event t (RequesterData request))
-> Event t (IntMap Any) -> Event t (RequesterData request)
forall a b. (a -> b) -> a -> b
$ IntMap (Event t Any) -> Event t (IntMap Any)
forall {k} (t :: k) a.
Reflex t =>
IntMap (Event t a) -> Event t (IntMap a)
mergeInt (IntMap (Event t Any) -> Event t (IntMap Any))
-> IntMap (Event t Any) -> Event t (IntMap Any)
forall a b. (a -> b) -> a -> b
$ [(Int, Event t Any)] -> IntMap (Event t Any)
forall a. [(Int, a)] -> IntMap a
IntMap.fromDistinctAscList ([(Int, Event t Any)] -> IntMap (Event t Any))
-> [(Int, Event t Any)] -> IntMap (Event t Any)
forall a b. (a -> b) -> a -> b
$ RequesterState t request -> [(Int, Event t Any)]
forall t (request :: * -> *).
RequesterState t request -> [(Int, Event t Any)]
_requesterState_requests RequesterState t request
s)
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
withRequesterT :: forall t (m :: * -> *) (req :: * -> *) (req' :: * -> *)
(rsp' :: * -> *) (rsp :: * -> *) a.
(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
withRequesterT forall x. req x -> req' x
freq forall x. rsp' x -> rsp x
frsp RequesterT t req rsp m a
child = do
rec let rsp :: Event t (RequesterData rsp)
rsp = (RequesterData rsp' -> RequesterData rsp)
-> Event t (RequesterData rsp') -> Event t (RequesterData rsp)
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Identity (RequesterData rsp) -> RequesterData rsp
forall a. Identity a -> a
runIdentity (Identity (RequesterData rsp) -> RequesterData rsp)
-> (RequesterData rsp' -> Identity (RequesterData rsp))
-> RequesterData rsp'
-> RequesterData rsp
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. rsp' a -> Identity (rsp a))
-> RequesterData rsp' -> Identity (RequesterData rsp)
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData (rsp a -> Identity (rsp a)
forall a. a -> Identity a
Identity (rsp a -> Identity (rsp a))
-> (rsp' a -> rsp a) -> rsp' a -> Identity (rsp a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. rsp' a -> rsp a
forall x. rsp' x -> rsp x
frsp)) Event t (RequesterData rsp')
rsp'
(a
a, Event t (RequesterData req)
req) <- m (a, Event t (RequesterData req))
-> RequesterT t req' rsp' m (a, Event t (RequesterData req))
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t req' rsp' m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, Event t (RequesterData req))
-> RequesterT t req' rsp' m (a, Event t (RequesterData req)))
-> m (a, Event t (RequesterData req))
-> RequesterT t req' rsp' m (a, Event t (RequesterData req))
forall a b. (a -> b) -> a -> b
$ RequesterT t req rsp m a
-> Event t (RequesterData rsp)
-> m (a, Event t (RequesterData req))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT RequesterT t req rsp m a
child Event t (RequesterData rsp)
rsp
Event t (RequesterData rsp')
rsp' <- (Event t (Entry rsp' Multi) -> Event t (RequesterData rsp'))
-> RequesterT t req' rsp' m (Event t (Entry rsp' Multi))
-> RequesterT t req' rsp' m (Event t (RequesterData rsp'))
forall a b.
(a -> b)
-> RequesterT t req' rsp' m a -> RequesterT t req' rsp' m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((EventSelectorInt t (RequesterData rsp')
-> Int -> Event t (RequesterData rsp'))
-> Int
-> EventSelectorInt t (RequesterData rsp')
-> Event t (RequesterData rsp')
forall a b c. (a -> b -> c) -> b -> a -> c
flip EventSelectorInt t (RequesterData rsp')
-> Int -> Event t (RequesterData rsp')
forall {k} (t :: k) a. EventSelectorInt t a -> Int -> Event t a
selectInt Int
0 (EventSelectorInt t (RequesterData rsp')
-> Event t (RequesterData rsp'))
-> (Event t (Entry rsp' Multi)
-> EventSelectorInt t (RequesterData rsp'))
-> Event t (Entry rsp' Multi)
-> Event t (RequesterData rsp')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (IntMap (RequesterData rsp'))
-> EventSelectorInt t (RequesterData rsp')
forall a. Event t (IntMap a) -> EventSelectorInt t a
forall {k} (t :: k) a.
Reflex t =>
Event t (IntMap a) -> EventSelectorInt t a
fanInt (Event t (IntMap (RequesterData rsp'))
-> EventSelectorInt t (RequesterData rsp'))
-> (Event t (Entry rsp' Multi)
-> Event t (IntMap (RequesterData rsp')))
-> Event t (Entry rsp' Multi)
-> EventSelectorInt t (RequesterData rsp')
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Entry rsp' Multi -> IntMap (RequesterData rsp'))
-> Event t (Entry rsp' Multi)
-> Event t (IntMap (RequesterData rsp'))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Entry rsp' Multi -> IntMap (RequesterData rsp')
forall (f :: * -> *). Entry f Multi -> IntMap (RequesterData f)
unMultiEntry) (RequesterT t req' rsp' m (Event t (Entry rsp' Multi))
-> RequesterT t req' rsp' m (Event t (RequesterData rsp')))
-> RequesterT t req' rsp' m (Event t (Entry rsp' Multi))
-> RequesterT t req' rsp' m (Event t (RequesterData rsp'))
forall a b. (a -> b) -> a -> b
$ Event t (Entry req' Multi)
-> RequesterT t req' rsp' m (Event t (Entry rsp' Multi))
forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' (Event t (Entry req' Multi)
-> RequesterT t req' rsp' m (Event t (Entry rsp' Multi)))
-> Event t (Entry req' Multi)
-> RequesterT t req' rsp' m (Event t (Entry rsp' Multi))
forall a b. (a -> b) -> a -> b
$
(RequesterData req' -> Entry req' Multi)
-> Event t (RequesterData req') -> Event t (Entry req' Multi)
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (IntMap (RequesterData req') -> Entry req' Multi
forall (f :: * -> *). IntMap (RequesterData f) -> Entry f Multi
multiEntry (IntMap (RequesterData req') -> Entry req' Multi)
-> (RequesterData req' -> IntMap (RequesterData req'))
-> RequesterData req'
-> Entry req' Multi
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Int -> RequesterData req' -> IntMap (RequesterData req')
forall a. Int -> a -> IntMap a
IntMap.singleton Int
0) (Event t (RequesterData req') -> Event t (Entry req' Multi))
-> Event t (RequesterData req') -> Event t (Entry req' Multi)
forall a b. (a -> b) -> a -> b
$ (RequesterData req -> RequesterData req')
-> Event t (RequesterData req) -> Event t (RequesterData req')
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Identity (RequesterData req') -> RequesterData req'
forall a. Identity a -> a
runIdentity (Identity (RequesterData req') -> RequesterData req')
-> (RequesterData req -> Identity (RequesterData req'))
-> RequesterData req
-> RequesterData req'
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a. req a -> Identity (req' a))
-> RequesterData req -> Identity (RequesterData req')
forall (m :: * -> *) (request :: * -> *) (response :: * -> *).
Applicative m =>
(forall a. request a -> m (response a))
-> RequesterData request -> m (RequesterData response)
traverseRequesterData (req' a -> Identity (req' a)
forall a. a -> Identity a
Identity (req' a -> Identity (req' a))
-> (req a -> req' a) -> req a -> Identity (req' a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. req a -> req' a
forall x. req x -> req' x
freq)) Event t (RequesterData req)
req
a -> RequesterT t req' rsp' m a
forall a. a -> RequesterT t req' rsp' m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
a
instance (Reflex t, Monad m) => Requester t (RequesterT t request response m) where
type Request (RequesterT t request response m) = request
type Response (RequesterT t request response m) = response
requesting :: forall a.
Event t (Request (RequesterT t request response m) a)
-> RequesterT
t
request
response
m
(Event t (Response (RequesterT t request response m) a))
requesting = (Event t (Entry response (Single a)) -> Event t (response a))
-> RequesterT
t request response m (Event t (Entry response (Single a)))
-> RequesterT t request response m (Event t (response a))
forall a b.
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Event t (Entry response (Single a)) -> Event t (response a)
forall {k} (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent (RequesterT
t request response m (Event t (Entry response (Single a)))
-> RequesterT t request response m (Event t (response a)))
-> (MyTagWrap request (Entry request (Single a))
-> RequesterT
t request response m (Event t (Entry response (Single a))))
-> MyTagWrap request (Entry request (Single a))
-> RequesterT t request response m (Event t (response a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MyTagWrap response (Entry response (Single a))
-> RequesterT
t request response m (Event t (Entry response (Single a)))
forall (m :: * -> *) t (request :: * -> *) (response :: * -> *) x.
Monad m =>
MyTagWrap response (Entry response x)
-> RequesterT t request response m (Event t (Entry response x))
responseFromTag (MyTagWrap response (Entry response (Single a))
-> RequesterT
t request response m (Event t (Entry response (Single a))))
-> (MyTagWrap request (Entry request (Single a))
-> MyTagWrap response (Entry response (Single a)))
-> MyTagWrap request (Entry request (Single a))
-> RequesterT
t request response m (Event t (Entry response (Single a)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MyTagWrap request (Entry request (Single a))
-> MyTagWrap response (Entry response (Single a))
forall (f :: * -> *) x (g :: * -> *).
MyTagWrap f (Entry f x) -> MyTagWrap g (Entry g x)
castMyTagWrap (MyTagWrap request (Entry request (Single a))
-> RequesterT t request response m (Event t (response a)))
-> (Event t (request a)
-> RequesterT
t
request
response
m
(MyTagWrap request (Entry request (Single a))))
-> Event t (request a)
-> RequesterT t request response m (Event t (response a))
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Event t (Entry request (Single a))
-> RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
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))
tagRequest (Event t (Entry request (Single a))
-> RequesterT
t
request
response
m
(MyTagWrap request (Entry request (Single a))))
-> (Event t (request a) -> Event t (Entry request (Single a)))
-> Event t (request a)
-> RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Event t (request a) -> Event t (Entry request (Single a))
forall {a}.
Event t (request a) -> Event t (Entry request (Single a))
forall {k} (t :: k) a b.
(Reflex t, Coercible a b) =>
Event t a -> Event t b
coerceEvent :: Event t (request a) -> Event t (Entry request (Single a)))
requesting_ :: forall a.
Event t (Request (RequesterT t request response m) a)
-> RequesterT t request response m ()
requesting_ = RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
-> RequesterT t request response m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
-> RequesterT t request response m ())
-> (Event t (request a)
-> RequesterT
t
request
response
m
(MyTagWrap request (Entry request (Single a))))
-> Event t (request a)
-> RequesterT t request response m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Entry request (Single a))
-> RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
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))
tagRequest (Event t (Entry request (Single a))
-> RequesterT
t
request
response
m
(MyTagWrap request (Entry request (Single a))))
-> (Event t (request a) -> Event t (Entry request (Single a)))
-> Event t (request a)
-> RequesterT
t request response m (MyTagWrap request (Entry request (Single a)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (request a -> Entry request (Single a))
-> Event t (request a) -> Event t (Entry request (Single a))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap request a -> Entry request (Single a)
forall (f :: * -> *) a. f a -> Entry f (Single a)
singleEntry
{-# INLINE tagRequest #-}
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))
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))
tagRequest Event t (Entry request x)
req = do
RequesterState t request
old <- StateT
(RequesterState t request)
(ReaderT (EventSelectorInt t Any) m)
(RequesterState t request)
-> RequesterT t request response m (RequesterState t request)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT StateT
(RequesterState t request)
(ReaderT (EventSelectorInt t Any) m)
(RequesterState t request)
forall s (m :: * -> *). MonadState s m => m s
get
let n :: Int
n = RequesterState t request -> Int
forall t (request :: * -> *). RequesterState t request -> Int
_requesterState_nextMyTag RequesterState t request
old Int -> Int -> Int
forall a. Bits a => a -> a -> a
.|. Proxy x -> Int
forall x (proxy :: * -> *). MyTagTypeOffset x => proxy x -> Int
forall (proxy :: * -> *). proxy x -> Int
myTagTypeOffset (Proxy x
forall {k} (t :: k). Proxy t
Proxy :: Proxy x)
t :: MyTagWrap request (Entry request x)
t = Int -> MyTagWrap request (Entry request x)
forall (f :: * -> *) x. Int -> MyTagWrap f x
MyTagWrap Int
n
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ()
-> RequesterT t request response m ()
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ()
-> RequesterT t request response m ())
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ()
-> RequesterT t request response m ()
forall a b. (a -> b) -> a -> b
$ RequesterState t request
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (RequesterState t request
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ())
-> RequesterState t request
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) ()
forall a b. (a -> b) -> a -> b
$ RequesterState
{ _requesterState_nextMyTag :: Int
_requesterState_nextMyTag = RequesterState t request -> Int
forall t (request :: * -> *). RequesterState t request -> Int
_requesterState_nextMyTag RequesterState t request
old Int -> Int -> Int
forall a. Num a => a -> a -> a
- Int
0x4
, _requesterState_requests :: [(Int, Event t Any)]
_requesterState_requests = (Int
n, (Event t (Entry request x) -> Event t Any
forall a b. a -> b
unsafeCoerce :: Event t (Entry request x) -> Event t Any) Event t (Entry request x)
req) (Int, Event t Any) -> [(Int, Event t Any)] -> [(Int, Event t Any)]
forall a. a -> [a] -> [a]
: RequesterState t request -> [(Int, Event t Any)]
forall t (request :: * -> *).
RequesterState t request -> [(Int, Event t Any)]
_requesterState_requests RequesterState t request
old
}
return MyTagWrap request (Entry request x)
t
{-# INLINE responseFromTag #-}
responseFromTag :: forall m t request response x. Monad m => MyTagWrap response (Entry response x) -> RequesterT t request response m (Event t (Entry response x))
responseFromTag :: forall (m :: * -> *) t (request :: * -> *) (response :: * -> *) x.
Monad m =>
MyTagWrap response (Entry response x)
-> RequesterT t request response m (Event t (Entry response x))
responseFromTag (MyTagWrap Int
t) = do
EventSelectorInt t Any
responses :: EventSelectorInt t Any <- StateT
(RequesterState t request)
(ReaderT (EventSelectorInt t Any) m)
(EventSelectorInt t Any)
-> RequesterT t request response m (EventSelectorInt t Any)
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT StateT
(RequesterState t request)
(ReaderT (EventSelectorInt t Any) m)
(EventSelectorInt t Any)
forall r (m :: * -> *). MonadReader r m => m r
ask
return $ (Event t Any -> Event t (Entry response x)
forall a b. a -> b
unsafeCoerce :: Event t Any -> Event t (Entry response x)) (Event t Any -> Event t (Entry response x))
-> Event t Any -> Event t (Entry response x)
forall a b. (a -> b) -> a -> b
$ EventSelectorInt t Any -> Int -> Event t Any
forall {k} (t :: k) a. EventSelectorInt t a -> Int -> Event t a
selectInt EventSelectorInt t Any
responses Int
t
instance MonadTrans (RequesterT t request response) where
lift :: forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
lift = StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a)
-> (m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a)
-> m a
-> RequesterT t request response m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ReaderT (EventSelectorInt t Any) m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
forall (m :: * -> *) a.
Monad m =>
m a -> StateT (RequesterState t request) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (ReaderT (EventSelectorInt t Any) m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a)
-> (m a -> ReaderT (EventSelectorInt t Any) m a)
-> m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> ReaderT (EventSelectorInt t Any) m a
forall (m :: * -> *) a.
Monad m =>
m a -> ReaderT (EventSelectorInt t Any) m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift
instance MFunctor (RequesterT t request response) where
hoist :: forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> RequesterT t request response m b
-> RequesterT t request response n b
hoist forall a. m a -> n a
f = StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b
-> RequesterT t request response n b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b
-> RequesterT t request response n b)
-> (RequesterT t request response m b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b)
-> RequesterT t request response m b
-> RequesterT t request response n b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (forall a.
ReaderT (EventSelectorInt t Any) m a
-> ReaderT (EventSelectorInt t Any) n a)
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b
forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> StateT (RequesterState t request) m b
-> StateT (RequesterState t request) n b
hoist ((forall a. m a -> n a)
-> ReaderT (EventSelectorInt t Any) m a
-> ReaderT (EventSelectorInt t Any) n a
forall {k} (t :: (* -> *) -> k -> *) (m :: * -> *) (n :: * -> *)
(b :: k).
(MFunctor t, Monad m) =>
(forall a. m a -> n a) -> t m b -> t n b
forall (m :: * -> *) (n :: * -> *) b.
Monad m =>
(forall a. m a -> n a)
-> ReaderT (EventSelectorInt t Any) m b
-> ReaderT (EventSelectorInt t Any) n b
hoist m a -> n a
forall a. m a -> n a
f) (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b)
-> (RequesterT t request response m b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) b)
-> RequesterT t request response m b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) n) b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. RequesterT t request response m b
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) b
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
RequesterT t request response m a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
unRequesterT
instance PerformEvent t m => PerformEvent t (RequesterT t request response m) where
type Performable (RequesterT t request response m) = Performable m
performEvent_ :: Event t (Performable (RequesterT t request response m) ())
-> RequesterT t request response m ()
performEvent_ = m () -> RequesterT t request response m ()
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RequesterT t request response m ())
-> (Event t (Performable m ()) -> m ())
-> Event t (Performable m ())
-> RequesterT t request response m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Performable m ()) -> m ()
forall t (m :: * -> *).
PerformEvent t m =>
Event t (Performable m ()) -> m ()
performEvent_
performEvent :: forall a.
Event t (Performable (RequesterT t request response m) a)
-> RequesterT t request response m (Event t a)
performEvent = m (Event t a) -> RequesterT t request response m (Event t a)
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> RequesterT t request response m (Event t a))
-> (Event t (Performable m a) -> m (Event t a))
-> Event t (Performable m a)
-> RequesterT t request response m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Performable m a) -> m (Event t a)
forall a. Event t (Performable m a) -> m (Event t a)
forall t (m :: * -> *) a.
PerformEvent t m =>
Event t (Performable m a) -> m (Event t a)
performEvent
instance MonadRef m => MonadRef (RequesterT t request response m) where
type Ref (RequesterT t request response m) = Ref m
newRef :: forall a.
a
-> RequesterT
t request response m (Ref (RequesterT t request response m) a)
newRef = m (Ref m a) -> RequesterT t request response m (Ref m a)
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Ref m a) -> RequesterT t request response m (Ref m a))
-> (a -> m (Ref m a))
-> a
-> RequesterT t request response m (Ref m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref m a)
forall a. a -> m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef
readRef :: forall a.
Ref (RequesterT t request response m) a
-> RequesterT t request response m a
readRef = m a -> RequesterT t request response m a
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RequesterT t request response m a)
-> (Ref m a -> m a) -> Ref m a -> RequesterT t request response m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> m a
forall a. Ref m a -> m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef
writeRef :: forall a.
Ref (RequesterT t request response m) a
-> a -> RequesterT t request response m ()
writeRef Ref (RequesterT t request response m) a
r = m () -> RequesterT t request response m ()
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> RequesterT t request response m ())
-> (a -> m ()) -> a -> RequesterT t request response m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> a -> m ()
forall a. Ref m a -> a -> m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> m ()
writeRef Ref m a
Ref (RequesterT t request response m) a
r
instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (RequesterT t request response m) where
newEventWithTrigger :: forall a.
(EventTrigger t a -> IO (IO ()))
-> RequesterT t request response m (Event t a)
newEventWithTrigger = m (Event t a) -> RequesterT t request response m (Event t a)
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> RequesterT t request response m (Event t a))
-> ((EventTrigger t a -> IO (IO ())) -> m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> RequesterT t request response m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (EventTrigger t a -> IO (IO ())) -> m (Event t a)
forall a. (EventTrigger t a -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
MonadReflexCreateTrigger t m =>
(EventTrigger t a -> IO (IO ())) -> m (Event t a)
newEventWithTrigger
newFanEventWithTrigger :: forall (k :: * -> *).
GCompare k =>
(forall a. k a -> EventTrigger t a -> IO (IO ()))
-> RequesterT t request response m (EventSelector t k)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
f = m (EventSelector t k)
-> RequesterT t request response m (EventSelector t k)
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (EventSelector t k)
-> RequesterT t request response m (EventSelector t k))
-> m (EventSelector t k)
-> RequesterT t request response m (EventSelector t k)
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
forall t (m :: * -> *) (k :: * -> *).
(MonadReflexCreateTrigger t m, GCompare k) =>
(forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
forall (k :: * -> *).
GCompare k =>
(forall a. k a -> EventTrigger t a -> IO (IO ()))
-> m (EventSelector t k)
newFanEventWithTrigger k a -> EventTrigger t a -> IO (IO ())
forall a. k a -> EventTrigger t a -> IO (IO ())
f
instance MonadReader r m => MonadReader r (RequesterT t request response m) where
ask :: RequesterT t request response m r
ask = m r -> RequesterT t request response m r
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m r
forall r (m :: * -> *). MonadReader r m => m r
ask
local :: forall a.
(r -> r)
-> RequesterT t request response m a
-> RequesterT t request response m a
local r -> r
f (RequesterT StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
a) = StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
forall t (request :: * -> *) (response :: * -> *) (m :: * -> *) a.
StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
RequesterT (StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a)
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> RequesterT t request response m a
forall a b. (a -> b) -> a -> b
$ (ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
-> ReaderT
(EventSelectorInt t Any) m (a, RequesterState t request))
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
-> StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
mapStateT ((m (a, RequesterState t request)
-> m (a, RequesterState t request))
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
forall (m :: * -> *) a (n :: * -> *) b r.
(m a -> n b) -> ReaderT r m a -> ReaderT r n b
mapReaderT ((m (a, RequesterState t request)
-> m (a, RequesterState t request))
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
-> ReaderT
(EventSelectorInt t Any) m (a, RequesterState t request))
-> (m (a, RequesterState t request)
-> m (a, RequesterState t request))
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
-> ReaderT (EventSelectorInt t Any) m (a, RequesterState t request)
forall a b. (a -> b) -> a -> b
$ (r -> r)
-> m (a, RequesterState t request)
-> m (a, RequesterState t request)
forall a. (r -> r) -> m a -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f) StateT
(RequesterState t request) (ReaderT (EventSelectorInt t Any) m) a
a
reader :: forall a. (r -> a) -> RequesterT t request response m a
reader = m a -> RequesterT t request response m a
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> RequesterT t request response m a)
-> ((r -> a) -> m a)
-> (r -> a)
-> RequesterT t request response m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> a) -> m a
forall a. (r -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
reader
instance (Reflex t, Adjustable t m, MonadHold t m, MonadFix m) => Adjustable t (RequesterT t request response m) where
runWithReplace :: forall a b.
RequesterT t request response m a
-> Event t (RequesterT t request response m b)
-> RequesterT t request response m (a, Event t b)
runWithReplace = (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)
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)
runWithReplaceRequesterTWith ((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))
-> (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)
forall a b. (a -> b) -> a -> b
$ \m a'
dm0 Event t (m b')
dm' -> m (a', Event t b')
-> RequesterT t request response m (a', Event t b')
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a', Event t b')
-> RequesterT t request response m (a', Event t b'))
-> m (a', Event t b')
-> RequesterT t request response m (a', Event t b')
forall a b. (a -> b) -> a -> b
$ m a' -> Event t (m b') -> m (a', Event t b')
forall a b. m a -> Event t (m b) -> m (a, Event t b)
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace m a'
dm0 Event t (m b')
dm'
traverseIntMapWithKeyWithAdjust :: forall v v'.
(Int -> v -> RequesterT t request response m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> RequesterT
t request response m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust = ((Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (PatchIntMap (Int, v))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v'))))
-> (PatchIntMap (Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request))))
-> (Incremental
t (PatchIntMap (Event t (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request))))
-> (Int -> v -> RequesterT t request response m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> RequesterT
t request response m (IntMap v', Event t (PatchIntMap v'))
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) =>
((Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (p (Int, 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))))
-> (Int -> v -> RequesterT t request response m v')
-> IntMap v
-> Event t (p v)
-> RequesterT t request response m (IntMap v', Event t (p v'))
traverseIntMapWithKeyWithAdjustRequesterTWith (\Int -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
f IntMap (Int, v)
dm0 Event t (PatchIntMap (Int, v))
dm' -> m (IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v'))))
-> m (IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
forall a b. (a -> b) -> a -> b
$ (Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (PatchIntMap (Int, v))
-> m (IntMap (Event t (IntMap (RequesterData request)), v'),
Event
t (PatchIntMap (Event t (IntMap (RequesterData request)), v')))
forall v v'.
(Int -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
forall t (m :: * -> *) v v'.
Adjustable t m =>
(Int -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust Int -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
f IntMap (Int, v)
dm0 Event t (PatchIntMap (Int, v))
dm') PatchIntMap (Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request)))
forall a. PatchIntMap a -> IntMap a
patchIntMapNewElementsMap Incremental
t (PatchIntMap (Event t (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request)))
forall a.
Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
forall {k} (t :: k) a.
Reflex t =>
Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
mergeIntIncremental
{-# INLINABLE traverseDMapWithKeyWithAdjust #-}
traverseDMapWithKeyWithAdjust :: forall (k :: * -> *) (v :: * -> *) (v' :: * -> *).
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'))
traverseDMapWithKeyWithAdjust = (forall (k' :: * -> *) (v1 :: * -> *) (v2 :: * -> *).
GCompare k' =>
(forall a. k' a -> v1 a -> m (v2 a))
-> DMap k' v1
-> Event t (PatchDMap k' v1)
-> RequesterT
t request response m (DMap k' v2, Event t (PatchDMap k' v2)))
-> (forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a) -> PatchDMap k v1 -> PatchDMap k v2)
-> (forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2) -> PatchDMap k v1 -> PatchMap (Some k) v2)
-> (forall v2. PatchMap (Some k) v2 -> Map (Some k) v2)
-> (forall a.
Incremental t (PatchMap (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 (PatchDMap k v)
-> RequesterT
t request response m (DMap k v', Event t (PatchDMap k v'))
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'))
traverseDMapWithKeyWithAdjustRequesterTWith (\forall a. k' a -> v1 a -> m (v2 a)
f DMap k' v1
dm0 Event t (PatchDMap k' v1)
dm' -> m (DMap k' v2, Event t (PatchDMap k' v2))
-> RequesterT
t request response m (DMap k' v2, Event t (PatchDMap k' v2))
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (DMap k' v2, Event t (PatchDMap k' v2))
-> RequesterT
t request response m (DMap k' v2, Event t (PatchDMap k' v2)))
-> m (DMap k' v2, Event t (PatchDMap k' v2))
-> RequesterT
t request response m (DMap k' v2, Event t (PatchDMap k' v2))
forall a b. (a -> b) -> a -> b
$ (forall a. k' a -> v1 a -> m (v2 a))
-> DMap k' v1
-> Event t (PatchDMap k' v1)
-> m (DMap k' v2, Event t (PatchDMap k' v2))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k v', Event t (PatchDMap k v'))
forall (k :: * -> *) (v :: * -> *) (v' :: * -> *).
GCompare k =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust k' a -> v1 a -> m (v2 a)
forall a. k' a -> v1 a -> m (v2 a)
f DMap k' v1
dm0 Event t (PatchDMap k' v1)
dm') (forall a. v1 a -> v2 a) -> PatchDMap k v1 -> PatchDMap k v2
forall {k1} (v :: k1 -> *) (v' :: k1 -> *) (k2 :: k1 -> *).
(forall (a :: k1). v a -> v' a)
-> PatchDMap k2 v -> PatchDMap k2 v'
forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a) -> PatchDMap k v1 -> PatchDMap k v2
mapPatchDMap (forall a. v1 a -> v2) -> PatchDMap k v1 -> PatchMap (Some k) v2
forall {k1} (v :: k1 -> *) v' (k2 :: k1 -> *).
(forall (a :: k1). v a -> v')
-> PatchDMap k2 v -> PatchMap (Some k2) v'
forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2) -> PatchDMap k v1 -> PatchMap (Some k) v2
weakenPatchDMapWith PatchMap (Some k) v2 -> Map (Some k) v2
forall v2. PatchMap (Some k) v2 -> Map (Some k) v2
forall k v. PatchMap k v -> Map k v
patchMapNewElementsMap Incremental t (PatchMap (Some k) (Event t a))
-> Event t (Map (Some k) a)
forall a.
Incremental t (PatchMap (Some k) (Event t a))
-> Event t (Map (Some k) a)
forall {k1} (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Incremental t (PatchMap k2 (Event t a)) -> Event t (Map k2 a)
mergeMapIncremental
traverseDMapWithKeyWithAdjustWithMove :: forall (k :: * -> *) (v :: * -> *) (v' :: * -> *).
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'))
traverseDMapWithKeyWithAdjustWithMove = (forall (k' :: * -> *) (v1 :: * -> *) (v2 :: * -> *).
GCompare k' =>
(forall a. k' a -> v1 a -> m (v2 a))
-> DMap k' v1
-> Event t (PatchDMapWithMove k' v1)
-> RequesterT
t
request
response
m
(DMap k' v2, Event t (PatchDMapWithMove k' v2)))
-> (forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a)
-> PatchDMapWithMove k v1 -> PatchDMapWithMove k v2)
-> (forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2)
-> PatchDMapWithMove k v1 -> PatchMapWithMove (Some k) v2)
-> (forall v2. PatchMapWithMove (Some k) v2 -> Map (Some k) v2)
-> (forall a.
Incremental t (PatchMapWithMove (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 (PatchDMapWithMove k v)
-> RequesterT
t request response m (DMap k v', Event t (PatchDMapWithMove k v'))
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'))
traverseDMapWithKeyWithAdjustRequesterTWith (\forall a. k' a -> v1 a -> m (v2 a)
f DMap k' v1
dm0 Event t (PatchDMapWithMove k' v1)
dm' -> m (DMap k' v2, Event t (PatchDMapWithMove k' v2))
-> RequesterT
t
request
response
m
(DMap k' v2, Event t (PatchDMapWithMove k' v2))
forall (m :: * -> *) a.
Monad m =>
m a -> RequesterT t request response m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (DMap k' v2, Event t (PatchDMapWithMove k' v2))
-> RequesterT
t
request
response
m
(DMap k' v2, Event t (PatchDMapWithMove k' v2)))
-> m (DMap k' v2, Event t (PatchDMapWithMove k' v2))
-> RequesterT
t
request
response
m
(DMap k' v2, Event t (PatchDMapWithMove k' v2))
forall a b. (a -> b) -> a -> b
$ (forall a. k' a -> v1 a -> m (v2 a))
-> DMap k' v1
-> Event t (PatchDMapWithMove k' v1)
-> m (DMap k' v2, Event t (PatchDMapWithMove k' v2))
forall t (m :: * -> *) (k :: * -> *) (v :: * -> *) (v' :: * -> *).
(Adjustable t m, GCompare k) =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
forall (k :: * -> *) (v :: * -> *) (v' :: * -> *).
GCompare k =>
(forall a. k a -> v a -> m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove k' a -> v1 a -> m (v2 a)
forall a. k' a -> v1 a -> m (v2 a)
f DMap k' v1
dm0 Event t (PatchDMapWithMove k' v1)
dm') (forall a. v1 a -> v2 a)
-> PatchDMapWithMove k v1 -> PatchDMapWithMove k v2
forall {k1} (k2 :: k1 -> *) (v :: k1 -> *) (v' :: k1 -> *).
(forall (a :: k1). v a -> v' a)
-> PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v'
forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a)
-> PatchDMapWithMove k v1 -> PatchDMapWithMove k v2
mapPatchDMapWithMove (forall a. v1 a -> v2)
-> PatchDMapWithMove k v1 -> PatchMapWithMove (Some k) v2
forall {k1} (k2 :: k1 -> *) (v :: k1 -> *) v'.
(forall (a :: k1). v a -> v')
-> PatchDMapWithMove k2 v -> PatchMapWithMove (Some k2) v'
forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2)
-> PatchDMapWithMove k v1 -> PatchMapWithMove (Some k) v2
weakenPatchDMapWithMoveWith PatchMapWithMove (Some k) v2 -> Map (Some k) v2
forall v2. PatchMapWithMove (Some k) v2 -> Map (Some k) v2
forall k v. PatchMapWithMove k v -> Map k v
patchMapWithMoveNewElementsMap Incremental t (PatchMapWithMove (Some k) (Event t a))
-> Event t (Map (Some k) a)
forall a.
Incremental t (PatchMapWithMove (Some k) (Event t a))
-> Event t (Map (Some k) a)
forall {k1} (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Incremental t (PatchMapWithMove k2 (Event t a))
-> Event t (Map k2 a)
mergeMapIncrementalWithMove
requesting' :: (MyTagTypeOffset x, Monad m) => Event t (Entry request x) -> RequesterT t request response m (Event t (Entry response x))
requesting' :: forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' = MyTagWrap response (Entry response x)
-> RequesterT t request response m (Event t (Entry response x))
forall (m :: * -> *) t (request :: * -> *) (response :: * -> *) x.
Monad m =>
MyTagWrap response (Entry response x)
-> RequesterT t request response m (Event t (Entry response x))
responseFromTag (MyTagWrap response (Entry response x)
-> RequesterT t request response m (Event t (Entry response x)))
-> (MyTagWrap request (Entry request x)
-> MyTagWrap response (Entry response x))
-> MyTagWrap request (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MyTagWrap request (Entry request x)
-> MyTagWrap response (Entry response x)
forall (f :: * -> *) x (g :: * -> *).
MyTagWrap f (Entry f x) -> MyTagWrap g (Entry g x)
castMyTagWrap (MyTagWrap request (Entry request x)
-> RequesterT t request response m (Event t (Entry response x)))
-> (Event t (Entry request x)
-> RequesterT
t request response m (MyTagWrap request (Entry request x)))
-> Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
forall (m :: * -> *) b c a.
Monad m =>
(b -> m c) -> (a -> m b) -> a -> m c
<=< Event t (Entry request x)
-> RequesterT
t request response m (MyTagWrap request (Entry request x))
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))
tagRequest
{-# INLINABLE runWithReplaceRequesterTWith #-}
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)
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)
runWithReplaceRequesterTWith forall a' b'.
m a'
-> Event t (m b')
-> RequesterT t request response m (a', Event t b')
f RequesterT t request response m a
a0 Event t (RequesterT t request response m b)
a' = do
rec Event t (Int, RequesterT t request response m b)
na' <- Int
-> Event t (RequesterT t request response m b)
-> RequesterT
t
request
response
m
(Event t (Int, RequesterT t request response m b))
forall {k} (t :: k) (m :: * -> *) b a.
(Reflex t, MonadHold t m, MonadFix m, Num b) =>
b -> Event t a -> m (Event t (b, a))
numberOccurrencesFrom Int
1 Event t (RequesterT t request response m b)
a'
Event t (IntMap (RequesterData response))
responses <- (Event t (Entry response Multi)
-> Event t (IntMap (RequesterData response)))
-> RequesterT t request response m (Event t (Entry response Multi))
-> RequesterT
t request response m (Event t (IntMap (RequesterData response)))
forall a b.
(a -> b)
-> RequesterT t request response m a
-> RequesterT t request response m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Entry response Multi -> IntMap (RequesterData response))
-> Event t (Entry response Multi)
-> Event t (IntMap (RequesterData response))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Entry response Multi -> IntMap (RequesterData response)
forall (f :: * -> *). Entry f Multi -> IntMap (RequesterData f)
unMultiEntry) (RequesterT t request response m (Event t (Entry response Multi))
-> RequesterT
t request response m (Event t (IntMap (RequesterData response))))
-> RequesterT t request response m (Event t (Entry response Multi))
-> RequesterT
t request response m (Event t (IntMap (RequesterData response)))
forall a b. (a -> b) -> a -> b
$ Event t (Entry request Multi)
-> RequesterT t request response m (Event t (Entry response Multi))
forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' (Event t (Entry request Multi)
-> RequesterT
t request response m (Event t (Entry response Multi)))
-> Event t (Entry request Multi)
-> RequesterT t request response m (Event t (Entry response Multi))
forall a b. (a -> b) -> a -> b
$ (IntMap (RequesterData request) -> Entry request Multi)
-> Event t (IntMap (RequesterData request))
-> Event t (Entry request Multi)
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap IntMap (RequesterData request) -> Entry request Multi
forall (f :: * -> *). IntMap (RequesterData f) -> Entry f Multi
multiEntry (Event t (IntMap (RequesterData request))
-> Event t (Entry request Multi))
-> Event t (IntMap (RequesterData request))
-> Event t (Entry request Multi)
forall a b. (a -> b) -> a -> b
$ Dynamic t (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (RequesterData request))
forall {k} (t :: k) a.
Reflex t =>
Dynamic t (Event t a) -> Event t a
switchPromptlyDyn Dynamic t (Event t (IntMap (RequesterData request)))
requests
let responses' :: EventSelectorInt t (RequesterData response)
responses' = Event t (IntMap (RequesterData response))
-> EventSelectorInt t (RequesterData response)
forall a. Event t (IntMap a) -> EventSelectorInt t a
forall {k} (t :: k) a.
Reflex t =>
Event t (IntMap a) -> EventSelectorInt t a
fanInt Event t (IntMap (RequesterData response))
responses
((a
result0, Event t (RequesterData request)
requests0), Event t (Int, (b, Event t (RequesterData request)))
v') <- m (a, Event t (RequesterData request))
-> Event t (m (Int, (b, Event t (RequesterData request))))
-> RequesterT
t
request
response
m
((a, Event t (RequesterData request)),
Event t (Int, (b, Event t (RequesterData request))))
forall a' b'.
m a'
-> Event t (m b')
-> RequesterT t request response m (a', Event t b')
f (RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT RequesterT t request response m a
a0 (EventSelectorInt t (RequesterData response)
-> Int -> Event t (RequesterData response)
forall {k} (t :: k) a. EventSelectorInt t a -> Int -> Event t a
selectInt EventSelectorInt t (RequesterData response)
responses' Int
0)) (Event t (m (Int, (b, Event t (RequesterData request))))
-> RequesterT
t
request
response
m
((a, Event t (RequesterData request)),
Event t (Int, (b, Event t (RequesterData request)))))
-> Event t (m (Int, (b, Event t (RequesterData request))))
-> RequesterT
t
request
response
m
((a, Event t (RequesterData request)),
Event t (Int, (b, Event t (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ ((Int, RequesterT t request response m b)
-> m (Int, (b, Event t (RequesterData request))))
-> Event t (Int, RequesterT t request response m b)
-> Event t (m (Int, (b, Event t (RequesterData request))))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (\(Int
n, RequesterT t request response m b
a) -> ((b, Event t (RequesterData request))
-> (Int, (b, Event t (RequesterData request))))
-> m (b, Event t (RequesterData request))
-> m (Int, (b, Event t (RequesterData request)))
forall a b. (a -> b) -> m a -> m b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((,) Int
n) (m (b, Event t (RequesterData request))
-> m (Int, (b, Event t (RequesterData request))))
-> m (b, Event t (RequesterData request))
-> m (Int, (b, Event t (RequesterData request)))
forall a b. (a -> b) -> a -> b
$ RequesterT t request response m b
-> Event t (RequesterData response)
-> m (b, Event t (RequesterData request))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT RequesterT t request response m b
a (Event t (RequesterData response)
-> m (b, Event t (RequesterData request)))
-> Event t (RequesterData response)
-> m (b, Event t (RequesterData request))
forall a b. (a -> b) -> a -> b
$ EventSelectorInt t (RequesterData response)
-> Int -> Event t (RequesterData response)
forall {k} (t :: k) a. EventSelectorInt t a -> Int -> Event t a
selectInt EventSelectorInt t (RequesterData response)
responses' Int
n) Event t (Int, RequesterT t request response m b)
na'
Dynamic t (Event t (IntMap (RequesterData request)))
requests <- Event t (IntMap (RequesterData request))
-> Event t (Event t (IntMap (RequesterData request)))
-> RequesterT
t
request
response
m
(Dynamic t (Event t (IntMap (RequesterData request))))
forall a.
a -> Event t a -> RequesterT t request response m (Dynamic t a)
forall {k} (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Dynamic t a)
holdDyn ((RequesterData request -> IntMap (RequesterData request))
-> Event t (RequesterData request)
-> Event t (IntMap (RequesterData request))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Int -> RequesterData request -> IntMap (RequesterData request)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
0) Event t (RequesterData request)
requests0) (Event t (Event t (IntMap (RequesterData request)))
-> RequesterT
t
request
response
m
(Dynamic t (Event t (IntMap (RequesterData request)))))
-> Event t (Event t (IntMap (RequesterData request)))
-> RequesterT
t
request
response
m
(Dynamic t (Event t (IntMap (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ ((Int, (b, Event t (RequesterData request)))
-> Event t (IntMap (RequesterData request)))
-> Event t (Int, (b, Event t (RequesterData request)))
-> Event t (Event t (IntMap (RequesterData request)))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (\(Int
n, (b
_, Event t (RequesterData request)
reqs)) -> (RequesterData request -> IntMap (RequesterData request))
-> Event t (RequesterData request)
-> Event t (IntMap (RequesterData request))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Int -> RequesterData request -> IntMap (RequesterData request)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
n) Event t (RequesterData request)
reqs) Event t (Int, (b, Event t (RequesterData request)))
v'
(a, Event t b) -> RequesterT t request response m (a, Event t b)
forall a. a -> RequesterT t request response m a
forall (m :: * -> *) a. Monad m => a -> m a
return (a
result0, ((Int, (b, Event t (RequesterData request))) -> b)
-> Event t (Int, (b, Event t (RequesterData request))) -> Event t b
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap ((b, Event t (RequesterData request)) -> b
forall a b. (a, b) -> a
fst ((b, Event t (RequesterData request)) -> b)
-> ((Int, (b, Event t (RequesterData request)))
-> (b, Event t (RequesterData request)))
-> (Int, (b, Event t (RequesterData request)))
-> b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Int, (b, Event t (RequesterData request)))
-> (b, Event t (RequesterData request))
forall a b. (a, b) -> b
snd) Event t (Int, (b, Event t (RequesterData request)))
v')
{-# INLINE traverseIntMapWithKeyWithAdjustRequesterTWith #-}
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
)
=> ( (IntMap.Key -> (IntMap.Key, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (IntMap.Key, v)
-> Event t (p (IntMap.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))))
-> (IntMap.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'))
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) =>
((Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (p (Int, 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))))
-> (Int -> v -> RequesterT t request response m v')
-> IntMap v
-> Event t (p v)
-> RequesterT t request response m (IntMap v', Event t (p v'))
traverseIntMapWithKeyWithAdjustRequesterTWith (Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (p (Int, v))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event t (p (Event t (IntMap (RequesterData request)), v')))
base p (Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request)))
patchNewElements Incremental t (p (Event t (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request)))
mergePatchIncremental Int -> v -> RequesterT t request response m v'
f IntMap v
dm0 Event t (p v)
dm' = do
rec Event t (Entry response Multi3)
response <- Event t (Entry request Multi3)
-> RequesterT
t request response m (Event t (Entry response Multi3))
forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' (Event t (Entry request Multi3)
-> RequesterT
t request response m (Event t (Entry response Multi3)))
-> Event t (Entry request Multi3)
-> RequesterT
t request response m (Event t (Entry response Multi3))
forall a b. (a -> b) -> a -> b
$ (IntMap (IntMap (RequesterData request)) -> Entry request Multi3)
-> Event t (IntMap (IntMap (RequesterData request)))
-> Event t (Entry request Multi3)
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap IntMap (IntMap (RequesterData request)) -> Entry request Multi3
pack (Event t (IntMap (IntMap (RequesterData request)))
-> Event t (Entry request Multi3))
-> Event t (IntMap (IntMap (RequesterData request)))
-> Event t (Entry request Multi3)
forall a b. (a -> b) -> a -> b
$ Event t (IntMap (IntMap (RequesterData request)))
promptRequests Event t (IntMap (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request)))
forall a. Monoid a => a -> a -> a
`mappend` Incremental t (p (Event t (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request)))
mergePatchIncremental Incremental t (p (Event t (IntMap (RequesterData request))))
requests
let responses :: EventSelectorInt t (IntMap (RequesterData response))
responses :: EventSelectorInt t (IntMap (RequesterData response))
responses = Event t (IntMap (IntMap (RequesterData response)))
-> EventSelectorInt t (IntMap (RequesterData response))
forall a. Event t (IntMap a) -> EventSelectorInt t a
forall {k} (t :: k) a.
Reflex t =>
Event t (IntMap a) -> EventSelectorInt t a
fanInt (Event t (IntMap (IntMap (RequesterData response)))
-> EventSelectorInt t (IntMap (RequesterData response)))
-> Event t (IntMap (IntMap (RequesterData response)))
-> EventSelectorInt t (IntMap (RequesterData response))
forall a b. (a -> b) -> a -> b
$ (Entry response Multi3 -> IntMap (IntMap (RequesterData response)))
-> Event t (Entry response Multi3)
-> Event t (IntMap (IntMap (RequesterData response)))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Entry response Multi3 -> IntMap (IntMap (RequesterData response))
unpack Event t (Entry response Multi3)
response
unpack :: Entry response Multi3 -> IntMap (IntMap (RequesterData response))
unpack :: Entry response Multi3 -> IntMap (IntMap (RequesterData response))
unpack = Entry response Multi3 -> IntMap (IntMap (RequesterData response))
Entry response Multi3 -> EntryContents response Multi3
forall (request :: * -> *) x.
Entry request x -> EntryContents request x
unEntry
pack :: IntMap (IntMap (RequesterData request)) -> Entry request Multi3
pack :: IntMap (IntMap (RequesterData request)) -> Entry request Multi3
pack = IntMap (IntMap (RequesterData request)) -> Entry request Multi3
EntryContents request Multi3 -> Entry request Multi3
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry
f' :: IntMap.Key -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
f' :: Int -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
f' Int
k (Int
n, v
v) = do
(v'
result, Event t (RequesterData request)
myRequests) <- RequesterT t request response m v'
-> Event t (RequesterData response)
-> m (v', Event t (RequesterData request))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT (Int -> v -> RequesterT t request response m v'
f Int
k v
v) (Event t (RequesterData response)
-> m (v', Event t (RequesterData request)))
-> Event t (RequesterData response)
-> m (v', Event t (RequesterData request))
forall a b. (a -> b) -> a -> b
$ (IntMap (RequesterData response) -> Maybe (RequesterData response))
-> Event t (IntMap (RequesterData response))
-> Event t (RequesterData response)
forall {k} (t :: k) a b.
Reflex t =>
(a -> Maybe b) -> Event t a -> Event t b
mapMaybeCheap (Int
-> IntMap (RequesterData response)
-> Maybe (RequesterData response)
forall a. Int -> IntMap a -> Maybe a
IntMap.lookup Int
n) (Event t (IntMap (RequesterData response))
-> Event t (RequesterData response))
-> Event t (IntMap (RequesterData response))
-> Event t (RequesterData response)
forall a b. (a -> b) -> a -> b
$ EventSelectorInt t (IntMap (RequesterData response))
-> Int -> Event t (IntMap (RequesterData response))
forall {k} (t :: k) a. EventSelectorInt t a -> Int -> Event t a
selectInt EventSelectorInt t (IntMap (RequesterData response))
responses Int
k
(Event t (IntMap (RequesterData request)), v')
-> m (Event t (IntMap (RequesterData request)), v')
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return ((RequesterData request -> IntMap (RequesterData request))
-> Event t (RequesterData request)
-> Event t (IntMap (RequesterData request))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Int -> RequesterData request -> IntMap (RequesterData request)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
n) Event t (RequesterData request)
myRequests, v'
result)
Event t (Int, p v)
ndm' <- Int
-> Event t (p v)
-> RequesterT t request response m (Event t (Int, p v))
forall {k} (t :: k) (m :: * -> *) b a.
(Reflex t, MonadHold t m, MonadFix m, Num b) =>
b -> Event t a -> m (Event t (b, a))
numberOccurrencesFrom Int
1 Event t (p v)
dm'
(IntMap (Event t (IntMap (RequesterData request)), v')
children0, Event t (p (Event t (IntMap (RequesterData request)), v'))
children') <- (Int
-> (Int, v) -> m (Event t (IntMap (RequesterData request)), v'))
-> IntMap (Int, v)
-> Event t (p (Int, v))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event t (p (Event t (IntMap (RequesterData request)), v')))
base Int -> (Int, v) -> m (Event t (IntMap (RequesterData request)), v')
f' ((v -> (Int, v)) -> IntMap v -> IntMap (Int, v)
forall a b. (a -> b) -> IntMap a -> IntMap b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((,) Int
0) IntMap v
dm0) (Event t (p (Int, v))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event t (p (Event t (IntMap (RequesterData request)), v'))))
-> Event t (p (Int, v))
-> RequesterT
t
request
response
m
(IntMap (Event t (IntMap (RequesterData request)), v'),
Event t (p (Event t (IntMap (RequesterData request)), v')))
forall a b. (a -> b) -> a -> b
$ ((Int, p v) -> p (Int, v))
-> Event t (Int, p v) -> Event t (p (Int, v))
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
n, p v
dm) -> (v -> (Int, v)) -> p v -> p (Int, v)
forall a b. (a -> b) -> p a -> p b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((,) Int
n) p v
dm) Event t (Int, p v)
ndm'
let result0 :: IntMap v'
result0 = ((Event t (IntMap (RequesterData request)), v') -> v')
-> IntMap (Event t (IntMap (RequesterData request)), v')
-> IntMap v'
forall a b. (a -> b) -> IntMap a -> IntMap b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Event t (IntMap (RequesterData request)), v') -> v'
forall a b. (a, b) -> b
snd IntMap (Event t (IntMap (RequesterData request)), v')
children0
result' :: Event t (p v')
result' = Event t (p (Event t (IntMap (RequesterData request)), v'))
-> (p (Event t (IntMap (RequesterData request)), v') -> p v')
-> Event t (p v')
forall {k} (t :: k) a b.
Reflex t =>
Event t a -> (a -> b) -> Event t b
fforCheap Event t (p (Event t (IntMap (RequesterData request)), v'))
children' ((p (Event t (IntMap (RequesterData request)), v') -> p v')
-> Event t (p v'))
-> (p (Event t (IntMap (RequesterData request)), v') -> p v')
-> Event t (p v')
forall a b. (a -> b) -> a -> b
$ ((Event t (IntMap (RequesterData request)), v') -> v')
-> p (Event t (IntMap (RequesterData request)), v') -> p v'
forall a b. (a -> b) -> p a -> p b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Event t (IntMap (RequesterData request)), v') -> v'
forall a b. (a, b) -> b
snd
requests0 :: IntMap (Event t (IntMap (RequesterData request)))
requests0 :: IntMap (Event t (IntMap (RequesterData request)))
requests0 = ((Event t (IntMap (RequesterData request)), v')
-> Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request)), v')
-> IntMap (Event t (IntMap (RequesterData request)))
forall a b. (a -> b) -> IntMap a -> IntMap b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Event t (IntMap (RequesterData request)), v')
-> Event t (IntMap (RequesterData request))
forall a b. (a, b) -> a
fst IntMap (Event t (IntMap (RequesterData request)), v')
children0
requests' :: Event t (p (Event t (IntMap (RequesterData request))))
requests' :: Event t (p (Event t (IntMap (RequesterData request))))
requests' = Event t (p (Event t (IntMap (RequesterData request)), v'))
-> (p (Event t (IntMap (RequesterData request)), v')
-> p (Event t (IntMap (RequesterData request))))
-> Event t (p (Event t (IntMap (RequesterData request))))
forall {k} (t :: k) a b.
Reflex t =>
Event t a -> (a -> b) -> Event t b
fforCheap Event t (p (Event t (IntMap (RequesterData request)), v'))
children' ((p (Event t (IntMap (RequesterData request)), v')
-> p (Event t (IntMap (RequesterData request))))
-> Event t (p (Event t (IntMap (RequesterData request)))))
-> (p (Event t (IntMap (RequesterData request)), v')
-> p (Event t (IntMap (RequesterData request))))
-> Event t (p (Event t (IntMap (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ ((Event t (IntMap (RequesterData request)), v')
-> Event t (IntMap (RequesterData request)))
-> p (Event t (IntMap (RequesterData request)), v')
-> p (Event t (IntMap (RequesterData request)))
forall a b. (a -> b) -> p a -> p b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Event t (IntMap (RequesterData request)), v')
-> Event t (IntMap (RequesterData request))
forall a b. (a, b) -> a
fst
promptRequests :: Event t (IntMap (IntMap (RequesterData request)))
promptRequests :: Event t (IntMap (IntMap (RequesterData request)))
promptRequests = Event t (Event t (IntMap (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request)))
forall a. Event t (Event t a) -> Event t a
forall {k} (t :: k) a. Reflex t => Event t (Event t a) -> Event t a
coincidence (Event t (Event t (IntMap (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request))))
-> Event t (Event t (IntMap (IntMap (RequesterData request))))
-> Event t (IntMap (IntMap (RequesterData request)))
forall a b. (a -> b) -> a -> b
$ (p (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request))))
-> Event t (p (Event t (IntMap (RequesterData request))))
-> Event t (Event t (IntMap (IntMap (RequesterData request))))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (IntMap (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request)))
forall {k} (t :: k) a.
Reflex t =>
IntMap (Event t a) -> Event t (IntMap a)
mergeInt (IntMap (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request))))
-> (p (Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request))))
-> p (Event t (IntMap (RequesterData request)))
-> Event t (IntMap (IntMap (RequesterData request)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p (Event t (IntMap (RequesterData request)))
-> IntMap (Event t (IntMap (RequesterData request)))
patchNewElements) Event t (p (Event t (IntMap (RequesterData request))))
requests'
Incremental t (p (Event t (IntMap (RequesterData request))))
requests <- PatchTarget (p (Event t (IntMap (RequesterData request))))
-> Event t (p (Event t (IntMap (RequesterData request))))
-> RequesterT
t
request
response
m
(Incremental t (p (Event t (IntMap (RequesterData request)))))
forall p.
Patch p =>
PatchTarget p
-> Event t p -> RequesterT t request response m (Incremental t p)
forall {k} (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental IntMap (Event t (IntMap (RequesterData request)))
PatchTarget (p (Event t (IntMap (RequesterData request))))
requests0 Event t (p (Event t (IntMap (RequesterData request))))
requests'
(IntMap v', Event t (p v'))
-> RequesterT t request response m (IntMap v', Event t (p v'))
forall a. a -> RequesterT t request response m a
forall (m :: * -> *) a. Monad m => a -> m a
return (IntMap v'
result0, Event t (p v')
result')
{-# INLINE traverseDMapWithKeyWithAdjustRequesterTWith #-}
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'))
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'))
traverseDMapWithKeyWithAdjustRequesterTWith 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))
base forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a) -> p k v1 -> p k v2
mapPatch forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2) -> p k v1 -> p' (Some k) v2
weakenPatchWith forall v2. p' (Some k) v2 -> Map (Some k) v2
patchNewElements forall a.
Incremental t (p' (Some k) (Event t a)) -> Event t (Map (Some k) a)
mergePatchIncremental forall a. k a -> v a -> RequesterT t request response m (v' a)
f DMap k v
dm0 Event t (p k v)
dm' = do
rec Event t (Entry response (Multi2 k))
response <- Event t (Entry request (Multi2 k))
-> RequesterT
t request response m (Event t (Entry response (Multi2 k)))
forall x (m :: * -> *) t (request :: * -> *) (response :: * -> *).
(MyTagTypeOffset x, Monad m) =>
Event t (Entry request x)
-> RequesterT t request response m (Event t (Entry response x))
requesting' (Event t (Entry request (Multi2 k))
-> RequesterT
t request response m (Event t (Entry response (Multi2 k))))
-> Event t (Entry request (Multi2 k))
-> RequesterT
t request response m (Event t (Entry response (Multi2 k)))
forall a b. (a -> b) -> a -> b
$ (Map (Some k) (IntMap (RequesterData request))
-> Entry request (Multi2 k))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
-> Event t (Entry request (Multi2 k))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Map (Some k) (IntMap (RequesterData request))
-> Entry request (Multi2 k)
pack (Event t (Map (Some k) (IntMap (RequesterData request)))
-> Event t (Entry request (Multi2 k)))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
-> Event t (Entry request (Multi2 k))
forall a b. (a -> b) -> a -> b
$ Event t (Map (Some k) (IntMap (RequesterData request)))
promptRequests Event t (Map (Some k) (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall a. Monoid a => a -> a -> a
`mappend` Incremental
t (p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall a.
Incremental t (p' (Some k) (Event t a)) -> Event t (Map (Some k) a)
mergePatchIncremental Incremental
t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests
let responses :: EventSelector t (Const2 (Some k) (IntMap (RequesterData response)))
responses :: EventSelector t (Const2 (Some k) (IntMap (RequesterData response)))
responses = Event t (Map (Some k) (IntMap (RequesterData response)))
-> EventSelector
t (Const2 (Some k) (IntMap (RequesterData response)))
forall {k1} (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Event t (Map k2 a) -> EventSelector t (Const2 k2 a)
fanMap (Event t (Map (Some k) (IntMap (RequesterData response)))
-> EventSelector
t (Const2 (Some k) (IntMap (RequesterData response))))
-> Event t (Map (Some k) (IntMap (RequesterData response)))
-> EventSelector
t (Const2 (Some k) (IntMap (RequesterData response)))
forall a b. (a -> b) -> a -> b
$ (Entry response (Multi2 k)
-> Map (Some k) (IntMap (RequesterData response)))
-> Event t (Entry response (Multi2 k))
-> Event t (Map (Some k) (IntMap (RequesterData response)))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap Entry response (Multi2 k)
-> Map (Some k) (IntMap (RequesterData response))
unpack Event t (Entry response (Multi2 k))
response
unpack :: Entry response (Multi2 k) -> Map (Some k) (IntMap (RequesterData response))
unpack :: Entry response (Multi2 k)
-> Map (Some k) (IntMap (RequesterData response))
unpack = Multi2Contents k response
-> Map (Some k) (IntMap (RequesterData response))
forall (k :: * -> *) (request :: * -> *).
Multi2Contents k request
-> Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values (Multi2Contents k response
-> Map (Some k) (IntMap (RequesterData response)))
-> (Entry response (Multi2 k) -> Multi2Contents k response)
-> Entry response (Multi2 k)
-> Map (Some k) (IntMap (RequesterData response))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Entry response (Multi2 k) -> Multi2Contents k response
Entry response (Multi2 k) -> EntryContents response (Multi2 k)
forall (request :: * -> *) x.
Entry request x -> EntryContents request x
unEntry
pack :: Map (Some k) (IntMap (RequesterData request)) -> Entry request (Multi2 k)
pack :: Map (Some k) (IntMap (RequesterData request))
-> Entry request (Multi2 k)
pack Map (Some k) (IntMap (RequesterData request))
m = EntryContents request (Multi2 k) -> Entry request (Multi2 k)
forall (request :: * -> *) x.
EntryContents request x -> Entry request x
Entry (EntryContents request (Multi2 k) -> Entry request (Multi2 k))
-> EntryContents request (Multi2 k) -> Entry request (Multi2 k)
forall a b. (a -> b) -> a -> b
$ Multi2Contents { _multi2Contents_values :: Map (Some k) (IntMap (RequesterData request))
_multi2Contents_values = Map (Some k) (IntMap (RequesterData request))
m, _multi2Contents_dict :: Dict (GCompare k)
_multi2Contents_dict = Dict (GCompare k)
forall (a :: Constraint). a => Dict a
Dict }
f' :: forall a. k a -> Compose ((,) Int) v a -> m (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a)
f' :: forall a.
k a
-> Compose ((,) Int) v a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a)
f' k a
k (Compose (Int
n, v a
v)) = do
(v' a
result, Event t (RequesterData request)
myRequests) <- RequesterT t request response m (v' a)
-> Event t (RequesterData response)
-> m (v' a, Event t (RequesterData request))
forall t (m :: * -> *) (request :: * -> *) (response :: * -> *) a.
(Reflex t, Monad m) =>
RequesterT t request response m a
-> Event t (RequesterData response)
-> m (a, Event t (RequesterData request))
runRequesterT (k a -> v a -> RequesterT t request response m (v' a)
forall a. k a -> v a -> RequesterT t request response m (v' a)
f k a
k v a
v) (Event t (RequesterData response)
-> m (v' a, Event t (RequesterData request)))
-> Event t (RequesterData response)
-> m (v' a, Event t (RequesterData request))
forall a b. (a -> b) -> a -> b
$ (IntMap (RequesterData response) -> Maybe (RequesterData response))
-> Event t (IntMap (RequesterData response))
-> Event t (RequesterData response)
forall {k} (t :: k) a b.
Reflex t =>
(a -> Maybe b) -> Event t a -> Event t b
mapMaybeCheap (Int
-> IntMap (RequesterData response)
-> Maybe (RequesterData response)
forall a. Int -> IntMap a -> Maybe a
IntMap.lookup Int
n) (Event t (IntMap (RequesterData response))
-> Event t (RequesterData response))
-> Event t (IntMap (RequesterData response))
-> Event t (RequesterData response)
forall a b. (a -> b) -> a -> b
$ EventSelector t (Const2 (Some k) (IntMap (RequesterData response)))
-> forall a.
Const2 (Some k) (IntMap (RequesterData response)) a -> Event t a
forall {k1} (t :: k1) (k2 :: * -> *).
EventSelector t k2 -> forall a. k2 a -> Event t a
select EventSelector t (Const2 (Some k) (IntMap (RequesterData response)))
responses (Some k
-> Const2
(Some k)
(IntMap (RequesterData response))
(IntMap (RequesterData response))
forall {x} a (b :: x). a -> Const2 a b b
Const2 (k a -> Some k
forall {k} (tag :: k -> *) (a :: k). tag a -> Some tag
Some k a
k))
Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a)
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a))
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a)
forall a b. (a -> b) -> a -> b
$ (Event t (IntMap (RequesterData request)), v' a)
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose ((RequesterData request -> IntMap (RequesterData request))
-> Event t (RequesterData request)
-> Event t (IntMap (RequesterData request))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Int -> RequesterData request -> IntMap (RequesterData request)
forall a. Int -> a -> IntMap a
IntMap.singleton Int
n) Event t (RequesterData request)
myRequests, v' a
result)
Event t (Int, p k v)
ndm' <- Int
-> Event t (p k v)
-> RequesterT t request response m (Event t (Int, p k v))
forall {k} (t :: k) (m :: * -> *) b a.
(Reflex t, MonadHold t m, MonadFix m, Num b) =>
b -> Event t a -> m (Event t (b, a))
numberOccurrencesFrom Int
1 Event t (p k v)
dm'
(DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
children0, Event
t
(p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'))
children') <- (forall a.
k a
-> Compose ((,) Int) v a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a))
-> DMap k (Compose ((,) Int) v)
-> Event t (p k (Compose ((,) Int) v))
-> RequesterT
t
request
response
m
(DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'),
Event
t
(p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')))
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))
base k a
-> Compose ((,) Int) v a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a)
forall a.
k a
-> Compose ((,) Int) v a
-> m (Compose
((,) (Event t (IntMap (RequesterData request)))) v' a)
f' ((forall v. v v -> Compose ((,) Int) v v)
-> DMap k v -> DMap k (Compose ((,) Int) v)
forall {k1} (f :: k1 -> *) (g :: k1 -> *) (k2 :: k1 -> *).
(forall (v :: k1). f v -> g v) -> DMap k2 f -> DMap k2 g
DMap.map (\v v
v -> (Int, v v) -> Compose ((,) Int) v v
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (Int
0, v v
v)) DMap k v
dm0) (Event t (p k (Compose ((,) Int) v))
-> RequesterT
t
request
response
m
(DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'),
Event
t
(p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v'))))
-> Event t (p k (Compose ((,) Int) v))
-> RequesterT
t
request
response
m
(DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'),
Event
t
(p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')))
forall a b. (a -> b) -> a -> b
$ ((Int, p k v) -> p k (Compose ((,) Int) v))
-> Event t (Int, p k v) -> Event t (p k (Compose ((,) Int) v))
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
n, p k v
dm) -> (forall v. v v -> Compose ((,) Int) v v)
-> p k v -> p k (Compose ((,) Int) v)
forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a) -> p k v1 -> p k v2
mapPatch (\v a
v -> (Int, v a) -> Compose ((,) Int) v a
forall {k} {k1} (f :: k -> *) (g :: k1 -> k) (a :: k1).
f (g a) -> Compose f g a
Compose (Int
n, v a
v)) p k v
dm) Event t (Int, p k v)
ndm'
let result0 :: DMap k v'
result0 = (forall v.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> v' v)
-> DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> DMap k v'
forall {k1} (f :: k1 -> *) (g :: k1 -> *) (k2 :: k1 -> *).
(forall (v :: k1). f v -> g v) -> DMap k2 f -> DMap k2 g
DMap.map ((Event t (IntMap (RequesterData request)), v' v) -> v' v
forall a b. (a, b) -> b
snd ((Event t (IntMap (RequesterData request)), v' v) -> v' v)
-> (Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> (Event t (IntMap (RequesterData request)), v' v))
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> v' v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> (Event t (IntMap (RequesterData request)), v' v)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose) DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
children0
result' :: Event t (p k v')
result' = Event
t
(p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'))
-> (p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v')
-> Event t (p k v')
forall {k} (t :: k) a b.
Reflex t =>
Event t a -> (a -> b) -> Event t b
fforCheap Event
t
(p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'))
children' ((p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v')
-> Event t (p k v'))
-> (p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v')
-> Event t (p k v')
forall a b. (a -> b) -> a -> b
$ (forall v.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> v' v)
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v'
forall (v1 :: * -> *) (v2 :: * -> *).
(forall a. v1 a -> v2 a) -> p k v1 -> p k v2
mapPatch ((forall v.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> v' v)
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v')
-> (forall v.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' v
-> v' v)
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p k v'
forall a b. (a -> b) -> a -> b
$ (Event t (IntMap (RequesterData request)), v' a) -> v' a
forall a b. (a, b) -> b
snd ((Event t (IntMap (RequesterData request)), v' a) -> v' a)
-> (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a))
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> v' a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose
requests0 :: Map (Some k) (Event t (IntMap (RequesterData request)))
requests0 :: Map (Some k) (Event t (IntMap (RequesterData request)))
requests0 = (forall a.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request)))
-> DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> Map (Some k) (Event t (IntMap (RequesterData request)))
forall {k1} (v :: k1 -> *) v' (k2 :: k1 -> *).
(forall (a :: k1). v a -> v') -> DMap k2 v -> Map (Some k2) v'
weakenDMapWith ((Event t (IntMap (RequesterData request)), v' a)
-> Event t (IntMap (RequesterData request))
forall a b. (a, b) -> a
fst ((Event t (IntMap (RequesterData request)), v' a)
-> Event t (IntMap (RequesterData request)))
-> (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a))
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose) DMap
k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
children0
requests' :: Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests' :: Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests' = Event
t
(p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'))
-> (p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
forall {k} (t :: k) a b.
Reflex t =>
Event t a -> (a -> b) -> Event t b
fforCheap Event
t
(p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v'))
children' ((p k (Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event
t (p' (Some k) (Event t (IntMap (RequesterData request)))))
-> (p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
forall a b. (a -> b) -> a -> b
$ (forall a.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request)))
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request)))
forall (v1 :: * -> *) v2.
(forall a. v1 a -> v2) -> p k v1 -> p' (Some k) v2
weakenPatchWith ((forall a.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request)))
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request))))
-> (forall a.
Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request)))
-> p k
(Compose ((,) (Event t (IntMap (RequesterData request)))) v')
-> p' (Some k) (Event t (IntMap (RequesterData request)))
forall a b. (a -> b) -> a -> b
$ (Event t (IntMap (RequesterData request)), v' a)
-> Event t (IntMap (RequesterData request))
forall a b. (a, b) -> a
fst ((Event t (IntMap (RequesterData request)), v' a)
-> Event t (IntMap (RequesterData request)))
-> (Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a))
-> Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> Event t (IntMap (RequesterData request))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Compose ((,) (Event t (IntMap (RequesterData request)))) v' a
-> (Event t (IntMap (RequesterData request)), v' a)
forall {k1} {k2} (f :: k1 -> *) (g :: k2 -> k1) (a :: k2).
Compose f g a -> f (g a)
getCompose
promptRequests :: Event t (Map (Some k) (IntMap (RequesterData request)))
promptRequests :: Event t (Map (Some k) (IntMap (RequesterData request)))
promptRequests = Event t (Event t (Map (Some k) (IntMap (RequesterData request))))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall a. Event t (Event t a) -> Event t a
forall {k} (t :: k) a. Reflex t => Event t (Event t a) -> Event t a
coincidence (Event t (Event t (Map (Some k) (IntMap (RequesterData request))))
-> Event t (Map (Some k) (IntMap (RequesterData request))))
-> Event
t (Event t (Map (Some k) (IntMap (RequesterData request))))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall a b. (a -> b) -> a -> b
$ (p' (Some k) (Event t (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request))))
-> Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event
t (Event t (Map (Some k) (IntMap (RequesterData request))))
forall {k} (t :: k) a b.
Reflex t =>
(a -> b) -> Event t a -> Event t b
fmapCheap (Map (Some k) (Event t (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall {k1} (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Map k2 (Event t a) -> Event t (Map k2 a)
mergeMap (Map (Some k) (Event t (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request))))
-> (p' (Some k) (Event t (IntMap (RequesterData request)))
-> Map (Some k) (Event t (IntMap (RequesterData request))))
-> p' (Some k) (Event t (IntMap (RequesterData request)))
-> Event t (Map (Some k) (IntMap (RequesterData request)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. p' (Some k) (Event t (IntMap (RequesterData request)))
-> Map (Some k) (Event t (IntMap (RequesterData request)))
forall v2. p' (Some k) v2 -> Map (Some k) v2
patchNewElements) Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests'
Incremental
t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests <- PatchTarget
(p' (Some k) (Event t (IntMap (RequesterData request))))
-> Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
-> RequesterT
t
request
response
m
(Incremental
t (p' (Some k) (Event t (IntMap (RequesterData request)))))
forall p.
Patch p =>
PatchTarget p
-> Event t p -> RequesterT t request response m (Incremental t p)
forall {k} (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental Map (Some k) (Event t (IntMap (RequesterData request)))
PatchTarget
(p' (Some k) (Event t (IntMap (RequesterData request))))
requests0 Event t (p' (Some k) (Event t (IntMap (RequesterData request))))
requests'
(DMap k v', Event t (p k v'))
-> RequesterT t request response m (DMap k v', Event t (p k v'))
forall a. a -> RequesterT t request response m a
forall (m :: * -> *) a. Monad m => a -> m a
return (DMap k v'
result0, Event t (p k v')
result')
data Decoder rawResponse response =
forall a. Decoder (RequesterDataKey a) (rawResponse -> response a)
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)
)
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))
matchResponsesWithRequests forall a. request a -> (rawRequest, rawResponse -> response a)
f Event t (RequesterData request)
send Event t (Int, rawResponse)
recv = (forall a. request a -> (rawRequest, rawResponse -> response a))
-> Event t (RequesterData request)
-> Event t (Map Int rawResponse)
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response))
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 (Map Int rawResponse)
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response))
matchResponseMapWithRequests request a -> (rawRequest, rawResponse -> response a)
forall a. request a -> (rawRequest, rawResponse -> response a)
f Event t (RequesterData request)
send (Event t (Map Int rawResponse)
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response)))
-> Event t (Map Int rawResponse)
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response))
forall a b. (a -> b) -> a -> b
$ (Int -> rawResponse -> Map Int rawResponse)
-> (Int, rawResponse) -> Map Int rawResponse
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry Int -> rawResponse -> Map Int rawResponse
forall k a. k -> a -> Map k a
Map.singleton ((Int, rawResponse) -> Map Int rawResponse)
-> Event t (Int, rawResponse) -> Event t (Map Int rawResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t (Int, rawResponse)
recv
matchResponseMapWithRequests
:: 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 (Map Int rawResponse)
-> m ( Event t (Map Int rawRequest)
, Event t (RequesterData response)
)
matchResponseMapWithRequests :: 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 (Map Int rawResponse)
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response))
matchResponseMapWithRequests forall a. request a -> (rawRequest, rawResponse -> response a)
f Event t (RequesterData request)
send Event t (Map Int rawResponse)
recv = do
rec Behavior t Int
nextId <- Int -> Event t Int -> m (Behavior t Int)
forall a. a -> Event t a -> m (Behavior t a)
forall {k} (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Behavior t a)
hold Int
1 (Event t Int -> m (Behavior t Int))
-> Event t Int -> m (Behavior t Int)
forall a b. (a -> b) -> a -> b
$ ((Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> Int)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> Event t Int
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
next, PatchMap Int (Decoder rawResponse response)
_, Map Int rawRequest
_) -> Int
next) Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
outgoing
Incremental t (PatchMap Int (Decoder rawResponse response))
waitingFor :: Incremental t (PatchMap Int (Decoder rawResponse response)) <-
PatchTarget (PatchMap Int (Decoder rawResponse response))
-> Event t (PatchMap Int (Decoder rawResponse response))
-> m (Incremental t (PatchMap Int (Decoder rawResponse response)))
forall p.
Patch p =>
PatchTarget p -> Event t p -> m (Incremental t p)
forall {k} (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental Map Int (Decoder rawResponse response)
PatchTarget (PatchMap Int (Decoder rawResponse response))
forall a. Monoid a => a
mempty (Event t (PatchMap Int (Decoder rawResponse response))
-> m (Incremental t (PatchMap Int (Decoder rawResponse response))))
-> Event t (PatchMap Int (Decoder rawResponse response))
-> m (Incremental t (PatchMap Int (Decoder rawResponse response)))
forall a b. (a -> b) -> a -> b
$ [Event t (PatchMap Int (Decoder rawResponse response))]
-> Event t (PatchMap Int (Decoder rawResponse response))
forall {k} (t :: k) a. Reflex t => [Event t a] -> Event t a
leftmost
[ ((Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> PatchMap Int (Decoder rawResponse response))
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> Event t (PatchMap Int (Decoder rawResponse response))
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
_, PatchMap Int (Decoder rawResponse response)
outstanding, Map Int rawRequest
_) -> PatchMap Int (Decoder rawResponse response)
outstanding) Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
outgoing
, (RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> PatchMap Int (Decoder rawResponse response)
forall a b. (a, b) -> b
snd ((RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> PatchMap Int (Decoder rawResponse response))
-> Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> Event t (PatchMap Int (Decoder rawResponse response))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
incoming
]
let outgoing :: Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
outgoing = Behavior t Int
-> Event t (RequesterData request)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
processOutgoing Behavior t Int
nextId Event t (RequesterData request)
send
incoming :: Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
incoming = Incremental t (PatchMap Int (Decoder rawResponse response))
-> Event t (Map Int rawResponse)
-> Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
forall v.
Incremental t (PatchMap Int (Decoder rawResponse response))
-> Event t (Map Int rawResponse)
-> Event t (RequesterData response, PatchMap Int v)
processIncoming Incremental t (PatchMap Int (Decoder rawResponse response))
waitingFor Event t (Map Int rawResponse)
recv
(Event t (Map Int rawRequest), Event t (RequesterData response))
-> m (Event t (Map Int rawRequest),
Event t (RequesterData response))
forall a. a -> m a
forall (m :: * -> *) a. Monad m => a -> m a
return (((Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> Map Int rawRequest)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> Event t (Map Int rawRequest)
forall a b. (a -> b) -> Event t a -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(Int
_, PatchMap Int (Decoder rawResponse response)
_, Map Int rawRequest
rawReqs) -> Map Int rawRequest
rawReqs) Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
outgoing, (RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> RequesterData response
forall a b. (a, b) -> a
fst ((RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> RequesterData response)
-> Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
-> Event t (RequesterData response)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event
t
(RequesterData response,
PatchMap Int (Decoder rawResponse response))
incoming)
where
processOutgoing
:: Behavior t Int
-> Event t (RequesterData request)
-> Event t ( Int
, PatchMap Int (Decoder rawResponse response)
, Map Int rawRequest )
processOutgoing :: Behavior t Int
-> Event t (RequesterData request)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
processOutgoing Behavior t Int
nextId Event t (RequesterData request)
out = ((RequesterData request
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event t (RequesterData request)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event t (RequesterData request)
-> (RequesterData request
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (RequesterData request
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event t (RequesterData request)
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
forall {k} (t :: k) a b.
Reflex t =>
(a -> PushM t b) -> Event t a -> Event t b
pushAlways Event t (RequesterData request)
out ((RequesterData request
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> (RequesterData request
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest))
-> Event
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
forall a b. (a -> b) -> a -> b
$ \RequesterData request
dm -> do
Int
oldNextId <- Behavior t Int -> PushM t Int
forall a. Behavior t a -> PushM t a
forall {k} (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample Behavior t Int
nextId
let ([(Int, rawRequest, Decoder rawResponse response)]
result, Int
newNextId) = (State Int [(Int, rawRequest, Decoder rawResponse response)]
-> Int -> ([(Int, rawRequest, Decoder rawResponse response)], Int))
-> Int
-> State Int [(Int, rawRequest, Decoder rawResponse response)]
-> ([(Int, rawRequest, Decoder rawResponse response)], Int)
forall a b c. (a -> b -> c) -> b -> a -> c
flip State Int [(Int, rawRequest, Decoder rawResponse response)]
-> Int -> ([(Int, rawRequest, Decoder rawResponse response)], Int)
forall s a. State s a -> s -> (a, s)
runState Int
oldNextId (State Int [(Int, rawRequest, Decoder rawResponse response)]
-> ([(Int, rawRequest, Decoder rawResponse response)], Int))
-> State Int [(Int, rawRequest, Decoder rawResponse response)]
-> ([(Int, rawRequest, Decoder rawResponse response)], Int)
forall a b. (a -> b) -> a -> b
$ [DSum RequesterDataKey request]
-> (DSum RequesterDataKey request
-> StateT
Int Identity (Int, rawRequest, Decoder rawResponse response))
-> State Int [(Int, rawRequest, Decoder rawResponse response)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM (RequesterData request -> [DSum RequesterDataKey request]
forall (f :: * -> *). RequesterData f -> [DSum RequesterDataKey f]
requesterDataToList RequesterData request
dm) ((DSum RequesterDataKey request
-> StateT
Int Identity (Int, rawRequest, Decoder rawResponse response))
-> State Int [(Int, rawRequest, Decoder rawResponse response)])
-> (DSum RequesterDataKey request
-> StateT
Int Identity (Int, rawRequest, Decoder rawResponse response))
-> State Int [(Int, rawRequest, Decoder rawResponse response)]
forall a b. (a -> b) -> a -> b
$ \(RequesterDataKey a
k :=> request a
v) -> do
Int
n <- StateT Int Identity Int
forall s (m :: * -> *). MonadState s m => m s
get
Int -> StateT Int Identity ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put (Int -> StateT Int Identity ()) -> Int -> StateT Int Identity ()
forall a b. (a -> b) -> a -> b
$ Int -> Int
forall a. Enum a => a -> a
succ Int
n
let (rawRequest
rawReq, rawResponse -> response a
rspF) = request a -> (rawRequest, rawResponse -> response a)
forall a. request a -> (rawRequest, rawResponse -> response a)
f request a
v
(Int, rawRequest, Decoder rawResponse response)
-> StateT
Int Identity (Int, rawRequest, Decoder rawResponse response)
forall a. a -> StateT Int Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
return (Int
n, rawRequest
rawReq, RequesterDataKey a
-> (rawResponse -> response a) -> Decoder rawResponse response
forall rawResponse (response :: * -> *) a.
RequesterDataKey a
-> (rawResponse -> response a) -> Decoder rawResponse response
Decoder RequesterDataKey a
k rawResponse -> response a
rspF)
patchWaitingFor :: PatchMap Int (Decoder rawResponse response)
patchWaitingFor = Map Int (Maybe (Decoder rawResponse response))
-> PatchMap Int (Decoder rawResponse response)
forall k v. Map k (Maybe v) -> PatchMap k v
PatchMap (Map Int (Maybe (Decoder rawResponse response))
-> PatchMap Int (Decoder rawResponse response))
-> Map Int (Maybe (Decoder rawResponse response))
-> PatchMap Int (Decoder rawResponse response)
forall a b. (a -> b) -> a -> b
$ [(Int, Maybe (Decoder rawResponse response))]
-> Map Int (Maybe (Decoder rawResponse response))
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Int, Maybe (Decoder rawResponse response))]
-> Map Int (Maybe (Decoder rawResponse response)))
-> [(Int, Maybe (Decoder rawResponse response))]
-> Map Int (Maybe (Decoder rawResponse response))
forall a b. (a -> b) -> a -> b
$
(\(Int
n, rawRequest
_, Decoder rawResponse response
dec) -> (Int
n, Decoder rawResponse response
-> Maybe (Decoder rawResponse response)
forall a. a -> Maybe a
Just Decoder rawResponse response
dec)) ((Int, rawRequest, Decoder rawResponse response)
-> (Int, Maybe (Decoder rawResponse response)))
-> [(Int, rawRequest, Decoder rawResponse response)]
-> [(Int, Maybe (Decoder rawResponse response))]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int, rawRequest, Decoder rawResponse response)]
result
toSend :: Map Int rawRequest
toSend = [(Int, rawRequest)] -> Map Int rawRequest
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(Int, rawRequest)] -> Map Int rawRequest)
-> [(Int, rawRequest)] -> Map Int rawRequest
forall a b. (a -> b) -> a -> b
$ (\(Int
n, rawRequest
rawReq, Decoder rawResponse response
_) -> (Int
n, rawRequest
rawReq)) ((Int, rawRequest, Decoder rawResponse response)
-> (Int, rawRequest))
-> [(Int, rawRequest, Decoder rawResponse response)]
-> [(Int, rawRequest)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [(Int, rawRequest, Decoder rawResponse response)]
result
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
-> PushM
t
(Int, PatchMap Int (Decoder rawResponse response),
Map Int rawRequest)
forall a. a -> PushM t a
forall (f :: * -> *) a. Applicative f => a -> f a
return (Int
newNextId, PatchMap Int (Decoder rawResponse response)
patchWaitingFor, Map Int rawRequest
toSend)
processIncoming
:: Incremental t (PatchMap Int (Decoder rawResponse response))
-> Event t (Map Int rawResponse)
-> Event t (RequesterData response, PatchMap Int v)
processIncoming :: forall v.
Incremental t (PatchMap Int (Decoder rawResponse response))
-> Event t (Map Int rawResponse)
-> Event t (RequesterData response, PatchMap Int v)
processIncoming Incremental t (PatchMap Int (Decoder rawResponse response))
waitingFor Event t (Map Int rawResponse)
inc = ((Map Int rawResponse
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Event t (Map Int rawResponse)
-> Event t (RequesterData response, PatchMap Int v))
-> Event t (Map Int rawResponse)
-> (Map Int rawResponse
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Event t (RequesterData response, PatchMap Int v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (Map Int rawResponse
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Event t (Map Int rawResponse)
-> Event t (RequesterData response, PatchMap Int v)
forall {k} (t :: k) a b.
Reflex t =>
(a -> PushM t (Maybe b)) -> Event t a -> Event t b
forall a b. (a -> PushM t (Maybe b)) -> Event t a -> Event t b
push Event t (Map Int rawResponse)
inc ((Map Int rawResponse
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Event t (RequesterData response, PatchMap Int v))
-> (Map Int rawResponse
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Event t (RequesterData response, PatchMap Int v)
forall a b. (a -> b) -> a -> b
$ \Map Int rawResponse
rspMap -> do
Map Int (Decoder rawResponse response)
wf <- Behavior t (Map Int (Decoder rawResponse response))
-> PushM t (Map Int (Decoder rawResponse response))
forall a. Behavior t a -> PushM t a
forall {k} (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t (Map Int (Decoder rawResponse response))
-> PushM t (Map Int (Decoder rawResponse response)))
-> Behavior t (Map Int (Decoder rawResponse response))
-> PushM t (Map Int (Decoder rawResponse response))
forall a b. (a -> b) -> a -> b
$ Incremental t (PatchMap Int (Decoder rawResponse response))
-> Behavior
t (PatchTarget (PatchMap Int (Decoder rawResponse response)))
forall p. Patch p => Incremental t p -> Behavior t (PatchTarget p)
forall {k} (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Behavior t (PatchTarget p)
currentIncremental Incremental t (PatchMap Int (Decoder rawResponse response))
waitingFor
let match :: rawResponse
-> Decoder rawResponse response -> RequesterData response
match rawResponse
rawRsp (Decoder RequesterDataKey a
k rawResponse -> response a
rspF) =
let rsp :: response a
rsp = rawResponse -> response a
rspF rawResponse
rawRsp
in RequesterDataKey a -> response a -> RequesterData response
forall a (f :: * -> *).
RequesterDataKey a -> f a -> RequesterData f
singletonRequesterData RequesterDataKey a
k response a
rsp
matches :: Map Int (RequesterData response)
matches = (rawResponse
-> Decoder rawResponse response -> RequesterData response)
-> Map Int rawResponse
-> Map Int (Decoder rawResponse response)
-> Map Int (RequesterData response)
forall k a b c.
Ord k =>
(a -> b -> c) -> Map k a -> Map k b -> Map k c
Map.intersectionWith rawResponse
-> Decoder rawResponse response -> RequesterData response
forall {rawResponse} {response :: * -> *}.
rawResponse
-> Decoder rawResponse response -> RequesterData response
match Map Int rawResponse
rspMap Map Int (Decoder rawResponse response)
wf
Maybe (RequesterData response, PatchMap Int v)
-> PushM t (Maybe (RequesterData response, PatchMap Int v))
forall a. a -> PushM t a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe (RequesterData response, PatchMap Int v)
-> PushM t (Maybe (RequesterData response, PatchMap Int v)))
-> Maybe (RequesterData response, PatchMap Int v)
-> PushM t (Maybe (RequesterData response, PatchMap Int v))
forall a b. (a -> b) -> a -> b
$ if Map Int (RequesterData response) -> Bool
forall k a. Map k a -> Bool
Map.null Map Int (RequesterData response)
matches then Maybe (RequesterData response, PatchMap Int v)
forall a. Maybe a
Nothing else (RequesterData response, PatchMap Int v)
-> Maybe (RequesterData response, PatchMap Int v)
forall a. a -> Maybe a
Just
((RequesterData response
-> RequesterData response -> RequesterData response)
-> RequesterData response
-> Map Int (RequesterData response)
-> RequesterData response
forall a b k. (a -> b -> a) -> a -> Map k b -> a
Map.foldl' RequesterData response
-> RequesterData response -> RequesterData response
forall (f :: * -> *).
RequesterData f -> RequesterData f -> RequesterData f
mergeRequesterData RequesterData response
forall (f :: * -> *). RequesterData f
emptyRequesterData Map Int (RequesterData response)
matches, Map Int (Maybe v) -> PatchMap Int v
forall k v. Map k (Maybe v) -> PatchMap k v
PatchMap (Map Int (Maybe v) -> PatchMap Int v)
-> Map Int (Maybe v) -> PatchMap Int v
forall a b. (a -> b) -> a -> b
$ Maybe v
forall a. Maybe a
Nothing Maybe v -> Map Int (RequesterData response) -> Map Int (Maybe v)
forall a b. a -> Map Int b -> Map Int a
forall (f :: * -> *) a b. Functor f => a -> f b -> f a
<$ Map Int (RequesterData response)
matches)