{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE StandaloneDeriving #-}
#ifdef USE_REFLEX_OPTIMIZER
{-# OPTIONS_GHC -fplugin=Reflex.Optimizer #-}
#endif
module Reflex.DynamicWriter.Base
( DynamicWriterT (..)
, runDynamicWriterT
, withDynamicWriterT
) where
import Control.Monad.Exception
import Control.Monad.Identity
import Control.Monad.IO.Class
import Control.Monad.Primitive
import Control.Monad.Reader
import Control.Monad.Ref
import Control.Monad.State.Strict
import Data.Align
import Data.Dependent.Map (DMap)
import qualified Data.Dependent.Map as DMap
import Data.FastMutableIntMap
import Data.Functor.Misc
import Data.IntMap (IntMap)
import qualified Data.IntMap as IntMap
import Data.Map (Map)
import qualified Data.Map as Map
import Data.Semigroup (Semigroup(..))
import Data.Some (Some)
import Data.These
import Reflex.Adjustable.Class
import Reflex.Class
import Reflex.DynamicWriter.Class
import Reflex.EventWriter.Class (EventWriter, tellEvent)
import Reflex.Host.Class
import qualified Data.Patch.MapWithMove as MapWithMove
import Reflex.PerformEvent.Class
import Reflex.PostBuild.Class
import Reflex.Query.Class
import Reflex.Requester.Class
import Reflex.TriggerEvent.Class
instance MonadTrans (DynamicWriterT t w) where
lift :: m a -> DynamicWriterT t w m a
lift = StateT [Dynamic t w] m a -> DynamicWriterT t w m a
forall t w (m :: * -> *) a.
StateT [Dynamic t w] m a -> DynamicWriterT t w m a
DynamicWriterT (StateT [Dynamic t w] m a -> DynamicWriterT t w m a)
-> (m a -> StateT [Dynamic t w] m a)
-> m a
-> DynamicWriterT t w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. m a -> StateT [Dynamic t w] m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift
mapIncrementalMapValues :: (Reflex t, Patch (p v), Patch (p v'), PatchTarget (p v) ~ f v, PatchTarget (p v') ~ f v', Functor p, Functor f) => (v -> v') -> Incremental t (p v) -> Incremental t (p v')
mapIncrementalMapValues :: (v -> v') -> Incremental t (p v) -> Incremental t (p v')
mapIncrementalMapValues f :: v -> v'
f = (PatchTarget (p v) -> PatchTarget (p v'))
-> (p v -> p v') -> Incremental t (p v) -> Incremental t (p v')
forall k (t :: k) p p'.
(Reflex t, Patch p, Patch p') =>
(PatchTarget p -> PatchTarget p')
-> (p -> p') -> Incremental t p -> Incremental t p'
unsafeMapIncremental ((v -> v') -> f v -> f v'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> v'
f) ((v -> v') -> p v -> p v'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> v'
f)
mergeDynIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Dynamic t v)) -> Incremental t (PatchMap k v)
mergeDynIncremental :: Incremental t (PatchMap k (Dynamic t v))
-> Incremental t (PatchMap k v)
mergeDynIncremental a :: Incremental t (PatchMap k (Dynamic t v))
a = PullM t (PatchTarget (PatchMap k v))
-> Event t (PatchMap k v) -> Incremental t (PatchMap k v)
forall k (t :: k) p.
(Reflex t, Patch p) =>
PullM t (PatchTarget p) -> Event t p -> Incremental t p
unsafeBuildIncremental ((Dynamic t v -> PullM t v)
-> Map k (Dynamic t v) -> PullM t (Map k v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PullM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PullM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PullM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current) (Map k (Dynamic t v) -> PullM t (Map k v))
-> PullM t (Map k (Dynamic t v)) -> PullM t (Map k v)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Behavior t (Map k (Dynamic t v)) -> PullM t (Map k (Dynamic t v))
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Incremental t (PatchMap k (Dynamic t v))
-> Behavior t (PatchTarget (PatchMap k (Dynamic t v)))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Behavior t (PatchTarget p)
currentIncremental Incremental t (PatchMap k (Dynamic t v))
a)) (Event t (PatchMap k v) -> Incremental t (PatchMap k v))
-> Event t (PatchMap k v) -> Incremental t (PatchMap k v)
forall a b. (a -> b) -> a -> b
$ Event t (PatchMap k v)
addedAndRemovedValues Event t (PatchMap k v)
-> Event t (PatchMap k v) -> Event t (PatchMap k v)
forall a. Semigroup a => a -> a -> a
<> Event t (PatchMap k v)
changedValues
where changedValues :: Event t (PatchMap k v)
changedValues = (Map k v -> PatchMap k v)
-> Event t (Map k v) -> Event t (PatchMap k v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Map k (Maybe v) -> PatchMap k v
forall k v. Map k (Maybe v) -> PatchMap k v
PatchMap (Map k (Maybe v) -> PatchMap k v)
-> (Map k v -> Map k (Maybe v)) -> Map k v -> PatchMap k v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v -> Maybe v) -> Map k v -> Map k (Maybe v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> Maybe v
forall a. a -> Maybe a
Just) (Event t (Map k v) -> Event t (PatchMap k v))
-> Event t (Map k v) -> Event t (PatchMap k v)
forall a b. (a -> b) -> a -> b
$ Incremental t (PatchMap k (Event t v)) -> Event t (Map k v)
forall k1 (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Incremental t (PatchMap k2 (Event t a)) -> Event t (Map k2 a)
mergeMapIncremental (Incremental t (PatchMap k (Event t v)) -> Event t (Map k v))
-> Incremental t (PatchMap k (Event t v)) -> Event t (Map k v)
forall a b. (a -> b) -> a -> b
$ (Dynamic t v -> Event t v)
-> Incremental t (PatchMap k (Dynamic t v))
-> Incremental t (PatchMap k (Event t v))
forall t (p :: * -> *) v v' (f :: * -> *).
(Reflex t, Patch (p v), Patch (p v'), PatchTarget (p v) ~ f v,
PatchTarget (p v') ~ f v', Functor p, Functor f) =>
(v -> v') -> Incremental t (p v) -> Incremental t (p v')
mapIncrementalMapValues Dynamic t v -> Event t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Event t a
updated Incremental t (PatchMap k (Dynamic t v))
a
addedAndRemovedValues :: Event t (PatchMap k v)
addedAndRemovedValues = ((PatchMap k (Dynamic t v) -> PushM t (PatchMap k v))
-> Event t (PatchMap k (Dynamic t v)) -> Event t (PatchMap k v))
-> Event t (PatchMap k (Dynamic t v))
-> (PatchMap k (Dynamic t v) -> PushM t (PatchMap k v))
-> Event t (PatchMap k v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (PatchMap k (Dynamic t v) -> PushM t (PatchMap k v))
-> Event t (PatchMap k (Dynamic t v)) -> Event t (PatchMap k v)
forall k (t :: k) a b.
Reflex t =>
(a -> PushM t b) -> Event t a -> Event t b
pushAlways (Incremental t (PatchMap k (Dynamic t v))
-> Event t (PatchMap k (Dynamic t v))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Event t p
updatedIncremental Incremental t (PatchMap k (Dynamic t v))
a) ((PatchMap k (Dynamic t v) -> PushM t (PatchMap k v))
-> Event t (PatchMap k v))
-> (PatchMap k (Dynamic t v) -> PushM t (PatchMap k v))
-> Event t (PatchMap k v)
forall a b. (a -> b) -> a -> b
$ \(PatchMap m :: Map k (Maybe (Dynamic t v))
m) -> Map k (Maybe v) -> PatchMap k v
forall k v. Map k (Maybe v) -> PatchMap k v
PatchMap (Map k (Maybe v) -> PatchMap k v)
-> PushM t (Map k (Maybe v)) -> PushM t (PatchMap k v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (Dynamic t v) -> PushM t (Maybe v))
-> Map k (Maybe (Dynamic t v)) -> PushM t (Map k (Maybe v))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Dynamic t v -> PushM t v)
-> Maybe (Dynamic t v) -> PushM t (Maybe v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PushM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PushM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PushM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current)) Map k (Maybe (Dynamic t v))
m
mergeIntMapDynIncremental :: Reflex t => Incremental t (PatchIntMap (Dynamic t v)) -> Incremental t (PatchIntMap v)
mergeIntMapDynIncremental :: Incremental t (PatchIntMap (Dynamic t v))
-> Incremental t (PatchIntMap v)
mergeIntMapDynIncremental a :: Incremental t (PatchIntMap (Dynamic t v))
a = PullM t (PatchTarget (PatchIntMap v))
-> Event t (PatchIntMap v) -> Incremental t (PatchIntMap v)
forall k (t :: k) p.
(Reflex t, Patch p) =>
PullM t (PatchTarget p) -> Event t p -> Incremental t p
unsafeBuildIncremental ((Dynamic t v -> PullM t v)
-> IntMap (Dynamic t v) -> PullM t (IntMap v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PullM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PullM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PullM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current) (IntMap (Dynamic t v) -> PullM t (IntMap v))
-> PullM t (IntMap (Dynamic t v)) -> PullM t (IntMap v)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Behavior t (IntMap (Dynamic t v)) -> PullM t (IntMap (Dynamic t v))
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Incremental t (PatchIntMap (Dynamic t v))
-> Behavior t (PatchTarget (PatchIntMap (Dynamic t v)))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Behavior t (PatchTarget p)
currentIncremental Incremental t (PatchIntMap (Dynamic t v))
a)) (Event t (PatchIntMap v) -> Incremental t (PatchIntMap v))
-> Event t (PatchIntMap v) -> Incremental t (PatchIntMap v)
forall a b. (a -> b) -> a -> b
$ Event t (PatchIntMap v)
addedAndRemovedValues Event t (PatchIntMap v)
-> Event t (PatchIntMap v) -> Event t (PatchIntMap v)
forall a. Semigroup a => a -> a -> a
<> Event t (PatchIntMap v)
changedValues
where changedValues :: Event t (PatchIntMap v)
changedValues = (IntMap v -> PatchIntMap v)
-> Event t (IntMap v) -> Event t (PatchIntMap v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (IntMap (Maybe v) -> PatchIntMap v
forall a. IntMap (Maybe a) -> PatchIntMap a
PatchIntMap (IntMap (Maybe v) -> PatchIntMap v)
-> (IntMap v -> IntMap (Maybe v)) -> IntMap v -> PatchIntMap v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (v -> Maybe v) -> IntMap v -> IntMap (Maybe v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap v -> Maybe v
forall a. a -> Maybe a
Just) (Event t (IntMap v) -> Event t (PatchIntMap v))
-> Event t (IntMap v) -> Event t (PatchIntMap v)
forall a b. (a -> b) -> a -> b
$ Incremental t (PatchIntMap (Event t v)) -> Event t (IntMap v)
forall k (t :: k) a.
Reflex t =>
Incremental t (PatchIntMap (Event t a)) -> Event t (IntMap a)
mergeIntMapIncremental (Incremental t (PatchIntMap (Event t v)) -> Event t (IntMap v))
-> Incremental t (PatchIntMap (Event t v)) -> Event t (IntMap v)
forall a b. (a -> b) -> a -> b
$ (Dynamic t v -> Event t v)
-> Incremental t (PatchIntMap (Dynamic t v))
-> Incremental t (PatchIntMap (Event t v))
forall t (p :: * -> *) v v' (f :: * -> *).
(Reflex t, Patch (p v), Patch (p v'), PatchTarget (p v) ~ f v,
PatchTarget (p v') ~ f v', Functor p, Functor f) =>
(v -> v') -> Incremental t (p v) -> Incremental t (p v')
mapIncrementalMapValues Dynamic t v -> Event t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Event t a
updated Incremental t (PatchIntMap (Dynamic t v))
a
addedAndRemovedValues :: Event t (PatchIntMap v)
addedAndRemovedValues = ((PatchIntMap (Dynamic t v) -> PushM t (PatchIntMap v))
-> Event t (PatchIntMap (Dynamic t v)) -> Event t (PatchIntMap v))
-> Event t (PatchIntMap (Dynamic t v))
-> (PatchIntMap (Dynamic t v) -> PushM t (PatchIntMap v))
-> Event t (PatchIntMap v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (PatchIntMap (Dynamic t v) -> PushM t (PatchIntMap v))
-> Event t (PatchIntMap (Dynamic t v)) -> Event t (PatchIntMap v)
forall k (t :: k) a b.
Reflex t =>
(a -> PushM t b) -> Event t a -> Event t b
pushAlways (Incremental t (PatchIntMap (Dynamic t v))
-> Event t (PatchIntMap (Dynamic t v))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Event t p
updatedIncremental Incremental t (PatchIntMap (Dynamic t v))
a) ((PatchIntMap (Dynamic t v) -> PushM t (PatchIntMap v))
-> Event t (PatchIntMap v))
-> (PatchIntMap (Dynamic t v) -> PushM t (PatchIntMap v))
-> Event t (PatchIntMap v)
forall a b. (a -> b) -> a -> b
$ \(PatchIntMap m :: IntMap (Maybe (Dynamic t v))
m) -> IntMap (Maybe v) -> PatchIntMap v
forall a. IntMap (Maybe a) -> PatchIntMap a
PatchIntMap (IntMap (Maybe v) -> PatchIntMap v)
-> PushM t (IntMap (Maybe v)) -> PushM t (PatchIntMap v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (Maybe (Dynamic t v) -> PushM t (Maybe v))
-> IntMap (Maybe (Dynamic t v)) -> PushM t (IntMap (Maybe v))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Dynamic t v -> PushM t v)
-> Maybe (Dynamic t v) -> PushM t (Maybe v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PushM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PushM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PushM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current)) IntMap (Maybe (Dynamic t v))
m
mergeDynIncrementalWithMove :: forall t k v. (Reflex t, Ord k) => Incremental t (PatchMapWithMove k (Dynamic t v)) -> Incremental t (PatchMapWithMove k v)
mergeDynIncrementalWithMove :: Incremental t (PatchMapWithMove k (Dynamic t v))
-> Incremental t (PatchMapWithMove k v)
mergeDynIncrementalWithMove a :: Incremental t (PatchMapWithMove k (Dynamic t v))
a = PullM t (PatchTarget (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k v)
-> Incremental t (PatchMapWithMove k v)
forall k (t :: k) p.
(Reflex t, Patch p) =>
PullM t (PatchTarget p) -> Event t p -> Incremental t p
unsafeBuildIncremental ((Dynamic t v -> PullM t v)
-> Map k (Dynamic t v) -> PullM t (Map k v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PullM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PullM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PullM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current) (Map k (Dynamic t v) -> PullM t (Map k v))
-> PullM t (Map k (Dynamic t v)) -> PullM t (Map k v)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Behavior t (Map k (Dynamic t v)) -> PullM t (Map k (Dynamic t v))
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Incremental t (PatchMapWithMove k (Dynamic t v))
-> Behavior t (PatchTarget (PatchMapWithMove k (Dynamic t v)))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Behavior t (PatchTarget p)
currentIncremental Incremental t (PatchMapWithMove k (Dynamic t v))
a)) (Event t (PatchMapWithMove k v)
-> Incremental t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k v)
-> Incremental t (PatchMapWithMove k v)
forall a b. (a -> b) -> a -> b
$ (These (PatchMapWithMove k v) (Map k v) -> PatchMapWithMove k v)
-> Event t (PatchMapWithMove k v)
-> Event t (Map k v)
-> Event t (PatchMapWithMove k v)
forall (f :: * -> *) a b c.
Semialign f =>
(These a b -> c) -> f a -> f b -> f c
alignWith These (PatchMapWithMove k v) (Map k v) -> PatchMapWithMove k v
f Event t (PatchMapWithMove k v)
addedAndRemovedValues Event t (Map k v)
changedValues
where changedValues :: Event t (Map k v)
changedValues = Incremental t (PatchMapWithMove k (Event t v)) -> Event t (Map k v)
forall k1 (t :: k1) k2 a.
(Reflex t, Ord k2) =>
Incremental t (PatchMapWithMove k2 (Event t a))
-> Event t (Map k2 a)
mergeMapIncrementalWithMove (Incremental t (PatchMapWithMove k (Event t v))
-> Event t (Map k v))
-> Incremental t (PatchMapWithMove k (Event t v))
-> Event t (Map k v)
forall a b. (a -> b) -> a -> b
$ (Dynamic t v -> Event t v)
-> Incremental t (PatchMapWithMove k (Dynamic t v))
-> Incremental t (PatchMapWithMove k (Event t v))
forall t (p :: * -> *) v v' (f :: * -> *).
(Reflex t, Patch (p v), Patch (p v'), PatchTarget (p v) ~ f v,
PatchTarget (p v') ~ f v', Functor p, Functor f) =>
(v -> v') -> Incremental t (p v) -> Incremental t (p v')
mapIncrementalMapValues Dynamic t v -> Event t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Event t a
updated Incremental t (PatchMapWithMove k (Dynamic t v))
a
addedAndRemovedValues :: Event t (PatchMapWithMove k v)
addedAndRemovedValues = ((PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k (Dynamic t v))
-> Event t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k (Dynamic t v))
-> (PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k v)
forall a b c. (a -> b -> c) -> b -> a -> c
flip (PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k (Dynamic t v))
-> Event t (PatchMapWithMove k v)
forall k (t :: k) a b.
Reflex t =>
(a -> PushM t b) -> Event t a -> Event t b
pushAlways (Incremental t (PatchMapWithMove k (Dynamic t v))
-> Event t (PatchMapWithMove k (Dynamic t v))
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Event t p
updatedIncremental Incremental t (PatchMapWithMove k (Dynamic t v))
a) ((PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k v))
-> (PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v))
-> Event t (PatchMapWithMove k v)
forall a b. (a -> b) -> a -> b
$ (Map k (NodeInfo k v) -> PatchMapWithMove k v)
-> PushM t (Map k (NodeInfo k v)) -> PushM t (PatchMapWithMove k v)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Map k (NodeInfo k v) -> PatchMapWithMove k v
forall k v. Map k (NodeInfo k v) -> PatchMapWithMove k v
unsafePatchMapWithMove (PushM t (Map k (NodeInfo k v)) -> PushM t (PatchMapWithMove k v))
-> (PatchMapWithMove k (Dynamic t v)
-> PushM t (Map k (NodeInfo k v)))
-> PatchMapWithMove k (Dynamic t v)
-> PushM t (PatchMapWithMove k v)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (NodeInfo k (Dynamic t v) -> PushM t (NodeInfo k v))
-> Map k (NodeInfo k (Dynamic t v))
-> PushM t (Map k (NodeInfo k v))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((Dynamic t v -> PushM t v)
-> NodeInfo k (Dynamic t v) -> PushM t (NodeInfo k v)
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM (Behavior t v -> PushM t v
forall k (t :: k) (m :: * -> *) a.
MonadSample t m =>
Behavior t a -> m a
sample (Behavior t v -> PushM t v)
-> (Dynamic t v -> Behavior t v) -> Dynamic t v -> PushM t v
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t v -> Behavior t v
forall k (t :: k) a. Reflex t => Dynamic t a -> Behavior t a
current)) (Map k (NodeInfo k (Dynamic t v))
-> PushM t (Map k (NodeInfo k v)))
-> (PatchMapWithMove k (Dynamic t v)
-> Map k (NodeInfo k (Dynamic t v)))
-> PatchMapWithMove k (Dynamic t v)
-> PushM t (Map k (NodeInfo k v))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PatchMapWithMove k (Dynamic t v)
-> Map k (NodeInfo k (Dynamic t v))
forall k v. PatchMapWithMove k v -> Map k (NodeInfo k v)
unPatchMapWithMove
f :: These (PatchMapWithMove k v) (Map k v) -> PatchMapWithMove k v
f :: These (PatchMapWithMove k v) (Map k v) -> PatchMapWithMove k v
f x :: These (PatchMapWithMove k v) (Map k v)
x = Map k (NodeInfo k v) -> PatchMapWithMove k v
forall k v. Map k (NodeInfo k v) -> PatchMapWithMove k v
unsafePatchMapWithMove (Map k (NodeInfo k v) -> PatchMapWithMove k v)
-> Map k (NodeInfo k v) -> PatchMapWithMove k v
forall a b. (a -> b) -> a -> b
$
let (p :: Map k (NodeInfo k v)
p, changed :: Map k v
changed) = case These (PatchMapWithMove k v) (Map k v)
x of
This p_ :: PatchMapWithMove k v
p_ -> (PatchMapWithMove k v -> Map k (NodeInfo k v)
forall k v. PatchMapWithMove k v -> Map k (NodeInfo k v)
unPatchMapWithMove PatchMapWithMove k v
p_, Map k v
forall a. Monoid a => a
mempty)
That c :: Map k v
c -> (Map k (NodeInfo k v)
forall a. Monoid a => a
mempty, Map k v
c)
These p_ :: PatchMapWithMove k v
p_ c :: Map k v
c -> (PatchMapWithMove k v -> Map k (NodeInfo k v)
forall k v. PatchMapWithMove k v -> Map k (NodeInfo k v)
unPatchMapWithMove PatchMapWithMove k v
p_, Map k v
c)
(pWithNewVals :: Map k (NodeInfo k v)
pWithNewVals, noLongerMoved :: [k]
noLongerMoved) = (State [k] (Map k (NodeInfo k v))
-> [k] -> (Map k (NodeInfo k v), [k]))
-> [k]
-> State [k] (Map k (NodeInfo k v))
-> (Map k (NodeInfo k v), [k])
forall a b c. (a -> b -> c) -> b -> a -> c
flip State [k] (Map k (NodeInfo k v))
-> [k] -> (Map k (NodeInfo k v), [k])
forall s a. State s a -> s -> (a, s)
runState [] (State [k] (Map k (NodeInfo k v)) -> (Map k (NodeInfo k v), [k]))
-> State [k] (Map k (NodeInfo k v)) -> (Map k (NodeInfo k v), [k])
forall a b. (a -> b) -> a -> b
$ Map k (NodeInfo k v)
-> (NodeInfo k v -> StateT [k] Identity (NodeInfo k v))
-> State [k] (Map k (NodeInfo k v))
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
t a -> (a -> m b) -> m (t b)
forM Map k (NodeInfo k v)
p ((NodeInfo k v -> StateT [k] Identity (NodeInfo k v))
-> State [k] (Map k (NodeInfo k v)))
-> (NodeInfo k v -> StateT [k] Identity (NodeInfo k v))
-> State [k] (Map k (NodeInfo k v))
forall a b. (a -> b) -> a -> b
$ (From k v -> StateT [k] Identity (From k v))
-> NodeInfo k v -> StateT [k] Identity (NodeInfo k v)
forall (f :: * -> *) k v.
Functor f =>
(From k v -> f (From k v)) -> NodeInfo k v -> f (NodeInfo k v)
MapWithMove.nodeInfoMapMFrom ((From k v -> StateT [k] Identity (From k v))
-> NodeInfo k v -> StateT [k] Identity (NodeInfo k v))
-> (From k v -> StateT [k] Identity (From k v))
-> NodeInfo k v
-> StateT [k] Identity (NodeInfo k v)
forall a b. (a -> b) -> a -> b
$ \case
MapWithMove.From_Insert v :: v
v -> From k v -> StateT [k] Identity (From k v)
forall (m :: * -> *) a. Monad m => a -> m a
return (From k v -> StateT [k] Identity (From k v))
-> From k v -> StateT [k] Identity (From k v)
forall a b. (a -> b) -> a -> b
$ v -> From k v
forall k v. v -> From k v
MapWithMove.From_Insert v
v
MapWithMove.From_Delete -> From k v -> StateT [k] Identity (From k v)
forall (m :: * -> *) a. Monad m => a -> m a
return From k v
forall k v. From k v
MapWithMove.From_Delete
MapWithMove.From_Move k :: k
k -> case k -> Map k v -> Maybe v
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup k
k Map k v
changed of
Nothing -> From k v -> StateT [k] Identity (From k v)
forall (m :: * -> *) a. Monad m => a -> m a
return (From k v -> StateT [k] Identity (From k v))
-> From k v -> StateT [k] Identity (From k v)
forall a b. (a -> b) -> a -> b
$ k -> From k v
forall k v. k -> From k v
MapWithMove.From_Move k
k
Just v :: v
v -> do
([k] -> [k]) -> StateT [k] Identity ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (k
kk -> [k] -> [k]
forall a. a -> [a] -> [a]
:)
From k v -> StateT [k] Identity (From k v)
forall (m :: * -> *) a. Monad m => a -> m a
return (From k v -> StateT [k] Identity (From k v))
-> From k v -> StateT [k] Identity (From k v)
forall a b. (a -> b) -> a -> b
$ v -> From k v
forall k v. v -> From k v
MapWithMove.From_Insert v
v
noLongerMovedMap :: Map k ()
noLongerMovedMap = [(k, ())] -> Map k ()
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(k, ())] -> Map k ()) -> [(k, ())] -> Map k ()
forall a b. (a -> b) -> a -> b
$ (k -> (k, ())) -> [k] -> [(k, ())]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (, ()) [k]
noLongerMoved
in (NodeInfo k v -> () -> Maybe (NodeInfo k v))
-> Map k (NodeInfo k v) -> Map k () -> Map k (NodeInfo k v)
forall k a b.
Ord k =>
(a -> b -> Maybe a) -> Map k a -> Map k b -> Map k a
Map.differenceWith (\e :: NodeInfo k v
e _ -> NodeInfo k v -> Maybe (NodeInfo k v)
forall a. a -> Maybe a
Just (NodeInfo k v -> Maybe (NodeInfo k v))
-> NodeInfo k v -> Maybe (NodeInfo k v)
forall a b. (a -> b) -> a -> b
$ To k -> NodeInfo k v -> NodeInfo k v
forall k v. To k -> NodeInfo k v -> NodeInfo k v
MapWithMove.nodeInfoSetTo To k
forall a. Maybe a
Nothing NodeInfo k v
e) Map k (NodeInfo k v)
pWithNewVals Map k ()
noLongerMovedMap
newtype DynamicWriterT t w m a = DynamicWriterT { DynamicWriterT t w m a -> StateT [Dynamic t w] m a
unDynamicWriterT :: StateT [Dynamic t w] m a }
deriving (a -> DynamicWriterT t w m b -> DynamicWriterT t w m a
(a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b
(forall a b.
(a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b)
-> (forall a b.
a -> DynamicWriterT t w m b -> DynamicWriterT t w m a)
-> Functor (DynamicWriterT t w m)
forall a b. a -> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall a b.
(a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b
forall t w (m :: * -> *) a b.
Functor m =>
a -> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall t w (m :: * -> *) a b.
Functor m =>
(a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
<$ :: a -> DynamicWriterT t w m b -> DynamicWriterT t w m a
$c<$ :: forall t w (m :: * -> *) a b.
Functor m =>
a -> DynamicWriterT t w m b -> DynamicWriterT t w m a
fmap :: (a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b
$cfmap :: forall t w (m :: * -> *) a b.
Functor m =>
(a -> b) -> DynamicWriterT t w m a -> DynamicWriterT t w m b
Functor, Functor (DynamicWriterT t w m)
a -> DynamicWriterT t w m a
Functor (DynamicWriterT t w m) =>
(forall a. a -> DynamicWriterT t w m a)
-> (forall a b.
DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b)
-> (forall a b c.
(a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w m c)
-> (forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b)
-> (forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a)
-> Applicative (DynamicWriterT t w m)
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b
(a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w m c
forall a. a -> DynamicWriterT t w m a
forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
forall a b.
DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b
forall a b c.
(a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w m c
forall t w (m :: * -> *). Monad m => Functor (DynamicWriterT t w m)
forall t w (m :: * -> *) a. Monad m => a -> DynamicWriterT t w m a
forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b
forall t w (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w 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
<* :: DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
$c<* :: forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
*> :: DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
$c*> :: forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
liftA2 :: (a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w m c
$cliftA2 :: forall t w (m :: * -> *) a b c.
Monad m =>
(a -> b -> c)
-> DynamicWriterT t w m a
-> DynamicWriterT t w m b
-> DynamicWriterT t w m c
<*> :: DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b
$c<*> :: forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m (a -> b)
-> DynamicWriterT t w m a -> DynamicWriterT t w m b
pure :: a -> DynamicWriterT t w m a
$cpure :: forall t w (m :: * -> *) a. Monad m => a -> DynamicWriterT t w m a
$cp1Applicative :: forall t w (m :: * -> *). Monad m => Functor (DynamicWriterT t w m)
Applicative, Applicative (DynamicWriterT t w m)
a -> DynamicWriterT t w m a
Applicative (DynamicWriterT t w m) =>
(forall a b.
DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w m b)
-> (forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b)
-> (forall a. a -> DynamicWriterT t w m a)
-> Monad (DynamicWriterT t w m)
DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w m b
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
forall a. a -> DynamicWriterT t w m a
forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
forall a b.
DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w m b
forall t w (m :: * -> *).
Monad m =>
Applicative (DynamicWriterT t w m)
forall t w (m :: * -> *) a. Monad m => a -> DynamicWriterT t w m a
forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w 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
return :: a -> DynamicWriterT t w m a
$creturn :: forall t w (m :: * -> *) a. Monad m => a -> DynamicWriterT t w m a
>> :: DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
$c>> :: forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m b
>>= :: DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w m b
$c>>= :: forall t w (m :: * -> *) a b.
Monad m =>
DynamicWriterT t w m a
-> (a -> DynamicWriterT t w m b) -> DynamicWriterT t w m b
$cp1Monad :: forall t w (m :: * -> *).
Monad m =>
Applicative (DynamicWriterT t w m)
Monad, Monad (DynamicWriterT t w m)
Monad (DynamicWriterT t w m) =>
(forall a. IO a -> DynamicWriterT t w m a)
-> MonadIO (DynamicWriterT t w m)
IO a -> DynamicWriterT t w m a
forall a. IO a -> DynamicWriterT t w m a
forall t w (m :: * -> *). MonadIO m => Monad (DynamicWriterT t w m)
forall t w (m :: * -> *) a.
MonadIO m =>
IO a -> DynamicWriterT t w m a
forall (m :: * -> *).
Monad m =>
(forall a. IO a -> m a) -> MonadIO m
liftIO :: IO a -> DynamicWriterT t w m a
$cliftIO :: forall t w (m :: * -> *) a.
MonadIO m =>
IO a -> DynamicWriterT t w m a
$cp1MonadIO :: forall t w (m :: * -> *). MonadIO m => Monad (DynamicWriterT t w m)
MonadIO, Monad (DynamicWriterT t w m)
Monad (DynamicWriterT t w m) =>
(forall a. (a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a)
-> MonadFix (DynamicWriterT t w m)
(a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
forall a. (a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
forall t w (m :: * -> *).
MonadFix m =>
Monad (DynamicWriterT t w m)
forall t w (m :: * -> *) a.
MonadFix m =>
(a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
forall (m :: * -> *).
Monad m =>
(forall a. (a -> m a) -> m a) -> MonadFix m
mfix :: (a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
$cmfix :: forall t w (m :: * -> *) a.
MonadFix m =>
(a -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
$cp1MonadFix :: forall t w (m :: * -> *).
MonadFix m =>
Monad (DynamicWriterT t w m)
MonadFix, MonadIO (DynamicWriterT t w m)
MonadException (DynamicWriterT t w m)
(MonadIO (DynamicWriterT t w m),
MonadException (DynamicWriterT t w m)) =>
(forall b.
((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b)
-> MonadAsyncException (DynamicWriterT t w m)
((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b
forall b.
((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b
forall t w (m :: * -> *).
MonadAsyncException m =>
MonadIO (DynamicWriterT t w m)
forall t w (m :: * -> *).
MonadAsyncException m =>
MonadException (DynamicWriterT t w m)
forall t w (m :: * -> *) b.
MonadAsyncException m =>
((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b
forall (m :: * -> *).
(MonadIO m, MonadException m) =>
(forall b. ((forall a. m a -> m a) -> m b) -> m b)
-> MonadAsyncException m
mask :: ((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b
$cmask :: forall t w (m :: * -> *) b.
MonadAsyncException m =>
((forall a. DynamicWriterT t w m a -> DynamicWriterT t w m a)
-> DynamicWriterT t w m b)
-> DynamicWriterT t w m b
$cp2MonadAsyncException :: forall t w (m :: * -> *).
MonadAsyncException m =>
MonadException (DynamicWriterT t w m)
$cp1MonadAsyncException :: forall t w (m :: * -> *).
MonadAsyncException m =>
MonadIO (DynamicWriterT t w m)
MonadAsyncException, Monad (DynamicWriterT t w m)
e -> DynamicWriterT t w m a
Monad (DynamicWriterT t w m) =>
(forall e a. Exception e => e -> DynamicWriterT t w m a)
-> (forall e a.
Exception e =>
DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a)
-> (forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a)
-> MonadException (DynamicWriterT t w m)
DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall e a. Exception e => e -> DynamicWriterT t w m a
forall e a.
Exception e =>
DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
forall a b.
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
forall t w (m :: * -> *).
MonadException m =>
Monad (DynamicWriterT t w m)
forall t w (m :: * -> *) e a.
(MonadException m, Exception e) =>
e -> DynamicWriterT t w m a
forall t w (m :: * -> *) e a.
(MonadException m, Exception e) =>
DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
forall t w (m :: * -> *) a b.
MonadException m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w 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
finally :: DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
$cfinally :: forall t w (m :: * -> *) a b.
MonadException m =>
DynamicWriterT t w m a
-> DynamicWriterT t w m b -> DynamicWriterT t w m a
catch :: DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
$ccatch :: forall t w (m :: * -> *) e a.
(MonadException m, Exception e) =>
DynamicWriterT t w m a
-> (e -> DynamicWriterT t w m a) -> DynamicWriterT t w m a
throw :: e -> DynamicWriterT t w m a
$cthrow :: forall t w (m :: * -> *) e a.
(MonadException m, Exception e) =>
e -> DynamicWriterT t w m a
$cp1MonadException :: forall t w (m :: * -> *).
MonadException m =>
Monad (DynamicWriterT t w m)
MonadException)
deriving instance MonadHold t m => MonadHold t (DynamicWriterT t w m)
deriving instance MonadSample t m => MonadSample t (DynamicWriterT t w m)
instance MonadRef m => MonadRef (DynamicWriterT t w m) where
type Ref (DynamicWriterT t w m) = Ref m
newRef :: a -> DynamicWriterT t w m (Ref (DynamicWriterT t w m) a)
newRef = m (Ref m a) -> DynamicWriterT t w m (Ref m a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Ref m a) -> DynamicWriterT t w m (Ref m a))
-> (a -> m (Ref m a)) -> a -> DynamicWriterT t w m (Ref m a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> m (Ref m a)
forall (m :: * -> *) a. MonadRef m => a -> m (Ref m a)
newRef
readRef :: Ref (DynamicWriterT t w m) a -> DynamicWriterT t w m a
readRef = m a -> DynamicWriterT t w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> DynamicWriterT t w m a)
-> (Ref m a -> m a) -> Ref m a -> DynamicWriterT t w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> m a
forall (m :: * -> *) a. MonadRef m => Ref m a -> m a
readRef
writeRef :: Ref (DynamicWriterT t w m) a -> a -> DynamicWriterT t w m ()
writeRef r :: Ref (DynamicWriterT t w m) a
r = m () -> DynamicWriterT t w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t w m ())
-> (a -> m ()) -> a -> DynamicWriterT t w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> a -> m ()
forall (m :: * -> *) a. MonadRef m => Ref m a -> a -> m ()
writeRef Ref m a
Ref (DynamicWriterT t w m) a
r
instance MonadAtomicRef m => MonadAtomicRef (DynamicWriterT t w m) where
atomicModifyRef :: Ref (DynamicWriterT t w m) a
-> (a -> (a, b)) -> DynamicWriterT t w m b
atomicModifyRef r :: Ref (DynamicWriterT t w m) a
r = m b -> DynamicWriterT t w m b
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m b -> DynamicWriterT t w m b)
-> ((a -> (a, b)) -> m b)
-> (a -> (a, b))
-> DynamicWriterT t w m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Ref m a -> (a -> (a, b)) -> m b
forall (m :: * -> *) a b.
MonadAtomicRef m =>
Ref m a -> (a -> (a, b)) -> m b
atomicModifyRef Ref m a
Ref (DynamicWriterT t w m) a
r
instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (DynamicWriterT t w m) where
newEventWithTrigger :: (EventTrigger t a -> IO (IO ()))
-> DynamicWriterT t w m (Event t a)
newEventWithTrigger = m (Event t a) -> DynamicWriterT t w m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> DynamicWriterT t w m (Event t a))
-> ((EventTrigger t a -> IO (IO ())) -> m (Event t a))
-> (EventTrigger t a -> IO (IO ()))
-> DynamicWriterT t w m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (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 a. k a -> EventTrigger t a -> IO (IO ()))
-> DynamicWriterT t w m (EventSelector t k)
newFanEventWithTrigger f :: forall a. k a -> EventTrigger t a -> IO (IO ())
f = m (EventSelector t k) -> DynamicWriterT t w m (EventSelector t k)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (EventSelector t k) -> DynamicWriterT t w m (EventSelector t k))
-> m (EventSelector t k)
-> DynamicWriterT t w 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)
newFanEventWithTrigger forall a. k a -> EventTrigger t a -> IO (IO ())
f
runDynamicWriterT :: (MonadFix m, Reflex t, Monoid w) => DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT :: DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT (DynamicWriterT a :: StateT [Dynamic t w] m a
a) = do
(result :: a
result, ws :: [Dynamic t w]
ws) <- StateT [Dynamic t w] m a -> [Dynamic t w] -> m (a, [Dynamic t w])
forall s (m :: * -> *) a. StateT s m a -> s -> m (a, s)
runStateT StateT [Dynamic t w] m a
a []
(a, Dynamic t w) -> m (a, Dynamic t w)
forall (m :: * -> *) a. Monad m => a -> m a
return (a
result, [Dynamic t w] -> Dynamic t w
forall a. Monoid a => [a] -> a
mconcat ([Dynamic t w] -> Dynamic t w) -> [Dynamic t w] -> Dynamic t w
forall a b. (a -> b) -> a -> b
$ [Dynamic t w] -> [Dynamic t w]
forall a. [a] -> [a]
reverse [Dynamic t w]
ws)
instance (Monad m, Monoid w, Reflex t) => DynamicWriter t w (DynamicWriterT t w m) where
tellDyn :: Dynamic t w -> DynamicWriterT t w m ()
tellDyn w :: Dynamic t w
w = StateT [Dynamic t w] m () -> DynamicWriterT t w m ()
forall t w (m :: * -> *) a.
StateT [Dynamic t w] m a -> DynamicWriterT t w m a
DynamicWriterT (StateT [Dynamic t w] m () -> DynamicWriterT t w m ())
-> StateT [Dynamic t w] m () -> DynamicWriterT t w m ()
forall a b. (a -> b) -> a -> b
$ ([Dynamic t w] -> [Dynamic t w]) -> StateT [Dynamic t w] m ()
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
modify (Dynamic t w
w Dynamic t w -> [Dynamic t w] -> [Dynamic t w]
forall a. a -> [a] -> [a]
:)
instance MonadReader r m => MonadReader r (DynamicWriterT t w m) where
ask :: DynamicWriterT t w m r
ask = m r -> DynamicWriterT t w m r
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 :: (r -> r) -> DynamicWriterT t w m a -> DynamicWriterT t w m a
local f :: r -> r
f (DynamicWriterT a :: StateT [Dynamic t w] m a
a) = StateT [Dynamic t w] m a -> DynamicWriterT t w m a
forall t w (m :: * -> *) a.
StateT [Dynamic t w] m a -> DynamicWriterT t w m a
DynamicWriterT (StateT [Dynamic t w] m a -> DynamicWriterT t w m a)
-> StateT [Dynamic t w] m a -> DynamicWriterT t w m a
forall a b. (a -> b) -> a -> b
$ (m (a, [Dynamic t w]) -> m (a, [Dynamic t w]))
-> StateT [Dynamic t w] m a -> StateT [Dynamic t w] m a
forall (m :: * -> *) a s (n :: * -> *) b.
(m (a, s) -> n (b, s)) -> StateT s m a -> StateT s n b
mapStateT ((r -> r) -> m (a, [Dynamic t w]) -> m (a, [Dynamic t w])
forall r (m :: * -> *) a. MonadReader r m => (r -> r) -> m a -> m a
local r -> r
f) StateT [Dynamic t w] m a
a
reader :: (r -> a) -> DynamicWriterT t w m a
reader = m a -> DynamicWriterT t w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> DynamicWriterT t w m a)
-> ((r -> a) -> m a) -> (r -> a) -> DynamicWriterT t w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (r -> a) -> m a
forall r (m :: * -> *) a. MonadReader r m => (r -> a) -> m a
reader
instance PerformEvent t m => PerformEvent t (DynamicWriterT t w m) where
type Performable (DynamicWriterT t w m) = Performable m
performEvent_ :: Event t (Performable (DynamicWriterT t w m) ())
-> DynamicWriterT t w m ()
performEvent_ = m () -> DynamicWriterT t w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t w m ())
-> (Event t (Performable m ()) -> m ())
-> Event t (Performable m ())
-> DynamicWriterT t w 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 :: Event t (Performable (DynamicWriterT t w m) a)
-> DynamicWriterT t w m (Event t a)
performEvent = m (Event t a) -> DynamicWriterT t w m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> DynamicWriterT t w m (Event t a))
-> (Event t (Performable m a) -> m (Event t a))
-> Event t (Performable m a)
-> DynamicWriterT t w m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. 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 TriggerEvent t m => TriggerEvent t (DynamicWriterT t w m) where
newTriggerEvent :: DynamicWriterT t w m (Event t a, a -> IO ())
newTriggerEvent = m (Event t a, a -> IO ())
-> DynamicWriterT t w m (Event t a, a -> IO ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO ())
newTriggerEvent
newTriggerEventWithOnComplete :: DynamicWriterT t w m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete = m (Event t a, a -> IO () -> IO ())
-> DynamicWriterT t w m (Event t a, a -> IO () -> IO ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t a, a -> IO () -> IO ())
forall t (m :: * -> *) a.
TriggerEvent t m =>
m (Event t a, a -> IO () -> IO ())
newTriggerEventWithOnComplete
newEventWithLazyTriggerWithOnComplete :: ((a -> IO () -> IO ()) -> IO (IO ()))
-> DynamicWriterT t w m (Event t a)
newEventWithLazyTriggerWithOnComplete = m (Event t a) -> DynamicWriterT t w m (Event t a)
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t a) -> DynamicWriterT t w m (Event t a))
-> (((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a))
-> ((a -> IO () -> IO ()) -> IO (IO ()))
-> DynamicWriterT t w m (Event t a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
forall t (m :: * -> *) a.
TriggerEvent t m =>
((a -> IO () -> IO ()) -> IO (IO ())) -> m (Event t a)
newEventWithLazyTriggerWithOnComplete
instance PostBuild t m => PostBuild t (DynamicWriterT t w m) where
getPostBuild :: DynamicWriterT t w m (Event t ())
getPostBuild = m (Event t ()) -> DynamicWriterT t w m (Event t ())
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Event t ())
forall t (m :: * -> *). PostBuild t m => m (Event t ())
getPostBuild
instance MonadState s m => MonadState s (DynamicWriterT t w m) where
get :: DynamicWriterT t w m s
get = m s -> DynamicWriterT t w m s
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m s
forall s (m :: * -> *). MonadState s m => m s
get
put :: s -> DynamicWriterT t w m ()
put = m () -> DynamicWriterT t w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t w m ())
-> (s -> m ()) -> s -> DynamicWriterT t w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. s -> m ()
forall s (m :: * -> *). MonadState s m => s -> m ()
put
instance PrimMonad m => PrimMonad (DynamicWriterT t w m) where
type PrimState (DynamicWriterT t w m) = PrimState m
primitive :: (State# (PrimState (DynamicWriterT t w m))
-> (# State# (PrimState (DynamicWriterT t w m)), a #))
-> DynamicWriterT t w m a
primitive = m a -> DynamicWriterT t w m a
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m a -> DynamicWriterT t w m a)
-> ((State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a)
-> (State# (PrimState m) -> (# State# (PrimState m), a #))
-> DynamicWriterT t w m a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
forall (m :: * -> *) a.
PrimMonad m =>
(State# (PrimState m) -> (# State# (PrimState m), a #)) -> m a
primitive
newtype DynamicWriterTLoweredResult t w v a = DynamicWriterTLoweredResult (v a, Dynamic t w)
instance (Adjustable t m, MonadFix m, Monoid w, MonadHold t m, Reflex t) => Adjustable t (DynamicWriterT t w m) where
runWithReplace :: DynamicWriterT t w m a
-> Event t (DynamicWriterT t w m b)
-> DynamicWriterT t w m (a, Event t b)
runWithReplace a0 :: DynamicWriterT t w m a
a0 a' :: Event t (DynamicWriterT t w m b)
a' = do
(result0 :: (a, Dynamic t w)
result0, result' :: Event t (b, Dynamic t w)
result') <- m ((a, Dynamic t w), Event t (b, Dynamic t w))
-> DynamicWriterT
t w m ((a, Dynamic t w), Event t (b, Dynamic t w))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m ((a, Dynamic t w), Event t (b, Dynamic t w))
-> DynamicWriterT
t w m ((a, Dynamic t w), Event t (b, Dynamic t w)))
-> m ((a, Dynamic t w), Event t (b, Dynamic t w))
-> DynamicWriterT
t w m ((a, Dynamic t w), Event t (b, Dynamic t w))
forall a b. (a -> b) -> a -> b
$ m (a, Dynamic t w)
-> Event t (m (b, Dynamic t w))
-> m ((a, Dynamic t w), Event t (b, Dynamic t w))
forall t (m :: * -> *) a b.
Adjustable t m =>
m a -> Event t (m b) -> m (a, Event t b)
runWithReplace (DynamicWriterT t w m a -> m (a, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT DynamicWriterT t w m a
a0) (Event t (m (b, Dynamic t w))
-> m ((a, Dynamic t w), Event t (b, Dynamic t w)))
-> Event t (m (b, Dynamic t w))
-> m ((a, Dynamic t w), Event t (b, Dynamic t w))
forall a b. (a -> b) -> a -> b
$ DynamicWriterT t w m b -> m (b, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT (DynamicWriterT t w m b -> m (b, Dynamic t w))
-> Event t (DynamicWriterT t w m b) -> Event t (m (b, Dynamic t w))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t (DynamicWriterT t w m b)
a'
Dynamic t w -> DynamicWriterT t w m ()
forall t w (m :: * -> *).
DynamicWriter t w m =>
Dynamic t w -> m ()
tellDyn (Dynamic t w -> DynamicWriterT t w m ())
-> (Dynamic t (Dynamic t w) -> Dynamic t w)
-> Dynamic t (Dynamic t w)
-> DynamicWriterT t w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Dynamic t (Dynamic t w) -> Dynamic t w
forall (m :: * -> *) a. Monad m => m (m a) -> m a
join (Dynamic t (Dynamic t w) -> DynamicWriterT t w m ())
-> DynamicWriterT t w m (Dynamic t (Dynamic t w))
-> DynamicWriterT t w m ()
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Dynamic t w
-> Event t (Dynamic t w)
-> DynamicWriterT t w m (Dynamic t (Dynamic t w))
forall k (t :: k) (m :: * -> *) a.
MonadHold t m =>
a -> Event t a -> m (Dynamic t a)
holdDyn ((a, Dynamic t w) -> Dynamic t w
forall a b. (a, b) -> b
snd (a, Dynamic t w)
result0) ((b, Dynamic t w) -> Dynamic t w
forall a b. (a, b) -> b
snd ((b, Dynamic t w) -> Dynamic t w)
-> Event t (b, Dynamic t w) -> Event t (Dynamic t w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t (b, Dynamic t w)
result')
(a, Event t b) -> DynamicWriterT t w m (a, Event t b)
forall (m :: * -> *) a. Monad m => a -> m a
return ((a, Dynamic t w) -> a
forall a b. (a, b) -> a
fst (a, Dynamic t w)
result0, (b, Dynamic t w) -> b
forall a b. (a, b) -> a
fst ((b, Dynamic t w) -> b) -> Event t (b, Dynamic t w) -> Event t b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Event t (b, Dynamic t w)
result')
traverseIntMapWithKeyWithAdjust :: (Key -> v -> DynamicWriterT t w m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> DynamicWriterT t w m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust = ((Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap (v', Dynamic t w),
Event t (PatchIntMap (v', Dynamic t w))))
-> (Incremental t (PatchIntMap (Dynamic t w))
-> Incremental t (PatchIntMap w))
-> (Key -> v -> DynamicWriterT t w m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> DynamicWriterT t w m (IntMap v', Event t (PatchIntMap v'))
forall t w v' (p :: * -> *) (p' :: * -> *) v (m :: * -> *).
(PatchTarget (p' (Dynamic t w)) ~ IntMap (Dynamic t w),
PatchTarget (p' w) ~ IntMap w, Patch (p' w),
Patch (p' (Dynamic t w)), MonadFix m, Monoid w, Reflex t,
MonadHold t m, Functor p, p ~ p') =>
((Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (p v)
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w))))
-> (Incremental t (p' (Dynamic t w)) -> Incremental t (p' w))
-> (Key -> v -> DynamicWriterT t w m v')
-> IntMap v
-> Event t (p v)
-> DynamicWriterT t w m (IntMap v', Event t (p v'))
traverseIntMapWithKeyWithAdjustImpl (Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap (v', Dynamic t w),
Event t (PatchIntMap (v', Dynamic t w)))
forall t (m :: * -> *) v v'.
Adjustable t m =>
(Key -> v -> m v')
-> IntMap v
-> Event t (PatchIntMap v)
-> m (IntMap v', Event t (PatchIntMap v'))
traverseIntMapWithKeyWithAdjust Incremental t (PatchIntMap (Dynamic t w))
-> Incremental t (PatchIntMap w)
forall t v.
Reflex t =>
Incremental t (PatchIntMap (Dynamic t v))
-> Incremental t (PatchIntMap v)
mergeIntMapDynIncremental
traverseDMapWithKeyWithAdjust :: (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> DynamicWriterT t w m (DMap k v', Event t (PatchDMap k v'))
traverseDMapWithKeyWithAdjust = ((forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (PatchDMap k (DynamicWriterTLoweredResult t w v'))))
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> PatchDMap k (DynamicWriterTLoweredResult t w v')
-> PatchDMap k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> PatchDMap k (DynamicWriterTLoweredResult t w v')
-> PatchMap (Some k) (Dynamic t w))
-> (Incremental t (PatchMap (Some k) (Dynamic t w))
-> Incremental t (PatchMap (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> DynamicWriterT t w m (DMap k v', Event t (PatchDMap k v'))
forall t w (k :: * -> *) (v' :: * -> *)
(p :: (* -> *) -> (* -> *) -> *) (p' :: * -> * -> *) (v :: * -> *)
(m :: * -> *).
(PatchTarget (p' (Some k) (Dynamic t w))
~ Map (Some k) (Dynamic t w),
PatchTarget (p' (Some k) w) ~ Map (Some k) w,
Patch (p' (Some k) w), Patch (p' (Some k) (Dynamic t w)),
MonadFix m, Monoid w, Reflex t, MonadHold t m) =>
((forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v'))))
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> (Incremental t (p' (Some k) (Dynamic t w))
-> Incremental t (p' (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (p k v)
-> DynamicWriterT t w m (DMap k v', Event t (p k v'))
traverseDMapWithKeyWithAdjustImpl (forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (PatchDMap k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (PatchDMap k (DynamicWriterTLoweredResult t w v')))
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'))
traverseDMapWithKeyWithAdjust (forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> PatchDMap k (DynamicWriterTLoweredResult t w v')
-> PatchDMap k v'
forall k1 (v :: k1 -> *) (v' :: k1 -> *) (k2 :: k1 -> *).
(forall (a :: k1). v a -> v' a)
-> PatchDMap k2 v -> PatchDMap k2 v'
mapPatchDMap (forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> PatchDMap k (DynamicWriterTLoweredResult t w v')
-> PatchMap (Some k) (Dynamic t w)
forall k1 (v :: k1 -> *) v' (k2 :: k1 -> *).
(forall (a :: k1). v a -> v')
-> PatchDMap k2 v -> PatchMap (Some k2) v'
weakenPatchDMapWith Incremental t (PatchMap (Some k) (Dynamic t w))
-> Incremental t (PatchMap (Some k) w)
forall t k v.
(Reflex t, Ord k) =>
Incremental t (PatchMap k (Dynamic t v))
-> Incremental t (PatchMap k v)
mergeDynIncremental
traverseDMapWithKeyWithAdjustWithMove :: (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> DynamicWriterT
t w m (DMap k v', Event t (PatchDMapWithMove k v'))
traverseDMapWithKeyWithAdjustWithMove = ((forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event
t (PatchDMapWithMove k (DynamicWriterTLoweredResult t w v'))))
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> PatchDMapWithMove k (DynamicWriterTLoweredResult t w v')
-> PatchDMapWithMove k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> PatchDMapWithMove k (DynamicWriterTLoweredResult t w v')
-> PatchMapWithMove (Some k) (Dynamic t w))
-> (Incremental t (PatchMapWithMove (Some k) (Dynamic t w))
-> Incremental t (PatchMapWithMove (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> DynamicWriterT
t w m (DMap k v', Event t (PatchDMapWithMove k v'))
forall t w (k :: * -> *) (v' :: * -> *)
(p :: (* -> *) -> (* -> *) -> *) (p' :: * -> * -> *) (v :: * -> *)
(m :: * -> *).
(PatchTarget (p' (Some k) (Dynamic t w))
~ Map (Some k) (Dynamic t w),
PatchTarget (p' (Some k) w) ~ Map (Some k) w,
Patch (p' (Some k) w), Patch (p' (Some k) (Dynamic t w)),
MonadFix m, Monoid w, Reflex t, MonadHold t m) =>
((forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v'))))
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> (Incremental t (p' (Some k) (Dynamic t w))
-> Incremental t (p' (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (p k v)
-> DynamicWriterT t w m (DMap k v', Event t (p k v'))
traverseDMapWithKeyWithAdjustImpl (forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (PatchDMapWithMove k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (PatchDMapWithMove k (DynamicWriterTLoweredResult t w v')))
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'))
traverseDMapWithKeyWithAdjustWithMove (forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> PatchDMapWithMove k (DynamicWriterTLoweredResult t w v')
-> PatchDMapWithMove k v'
forall k1 (k2 :: k1 -> *) (v :: k1 -> *) (v' :: k1 -> *).
(forall (a :: k1). v a -> v' a)
-> PatchDMapWithMove k2 v -> PatchDMapWithMove k2 v'
mapPatchDMapWithMove (forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> PatchDMapWithMove k (DynamicWriterTLoweredResult t w v')
-> PatchMapWithMove (Some k) (Dynamic t w)
forall k1 (k2 :: k1 -> *) (v :: k1 -> *) v'.
(forall (a :: k1). v a -> v')
-> PatchDMapWithMove k2 v -> PatchMapWithMove (Some k2) v'
weakenPatchDMapWithMoveWith Incremental t (PatchMapWithMove (Some k) (Dynamic t w))
-> Incremental t (PatchMapWithMove (Some k) w)
forall t k v.
(Reflex t, Ord k) =>
Incremental t (PatchMapWithMove k (Dynamic t v))
-> Incremental t (PatchMapWithMove k v)
mergeDynIncrementalWithMove
traverseDMapWithKeyWithAdjustImpl :: forall t w k v' p p' v m. (PatchTarget (p' (Some k) (Dynamic t w)) ~ Map (Some k) (Dynamic t w), PatchTarget (p' (Some k) w) ~ Map (Some k) w, Patch (p' (Some k) w), Patch (p' (Some k) (Dynamic t w)), MonadFix m, Monoid w, Reflex t, MonadHold t m)
=> ( (forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'), Event t (p k (DynamicWriterTLoweredResult t w v')))
)
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a) -> p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w) -> p k (DynamicWriterTLoweredResult t w v') -> p' (Some k) (Dynamic t w))
-> (Incremental t (p' (Some k) (Dynamic t w)) -> Incremental t (p' (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (p k v)
-> DynamicWriterT t w m (DMap k v', Event t (p k v'))
traverseDMapWithKeyWithAdjustImpl :: ((forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v'))))
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> ((forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> (Incremental t (p' (Some k) (Dynamic t w))
-> Incremental t (p' (Some k) w))
-> (forall a. k a -> v a -> DynamicWriterT t w m (v' a))
-> DMap k v
-> Event t (p k v)
-> DynamicWriterT t w m (DMap k v', Event t (p k v'))
traverseDMapWithKeyWithAdjustImpl base :: (forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
base mapPatch :: (forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> p k (DynamicWriterTLoweredResult t w v') -> p k v'
mapPatch weakenPatchWith :: (forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w)
weakenPatchWith mergeMyDynIncremental :: Incremental t (p' (Some k) (Dynamic t w))
-> Incremental t (p' (Some k) w)
mergeMyDynIncremental f :: forall a. k a -> v a -> DynamicWriterT t w m (v' a)
f (DMap k v
dm0 :: DMap k v) dm' :: Event t (p k v)
dm' = do
(result0 :: DMap k (DynamicWriterTLoweredResult t w v')
result0, result' :: Event t (p k (DynamicWriterTLoweredResult t w v'))
result') <- m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
-> DynamicWriterT
t
w
m
(DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
-> DynamicWriterT
t
w
m
(DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v'))))
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
-> DynamicWriterT
t
w
m
(DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
forall a b. (a -> b) -> a -> b
$ (forall a. k a -> v a -> m (DynamicWriterTLoweredResult t w v' a))
-> DMap k v
-> Event t (p k v)
-> m (DMap k (DynamicWriterTLoweredResult t w v'),
Event t (p k (DynamicWriterTLoweredResult t w v')))
base (\k :: k a
k v :: v a
v -> ((v' a, Dynamic t w) -> DynamicWriterTLoweredResult t w v' a)
-> m (v' a, Dynamic t w)
-> m (DynamicWriterTLoweredResult t w v' a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v' a, Dynamic t w) -> DynamicWriterTLoweredResult t w v' a
forall t w (v :: * -> *) a.
(v a, Dynamic t w) -> DynamicWriterTLoweredResult t w v a
DynamicWriterTLoweredResult (m (v' a, Dynamic t w) -> m (DynamicWriterTLoweredResult t w v' a))
-> m (v' a, Dynamic t w)
-> m (DynamicWriterTLoweredResult t w v' a)
forall a b. (a -> b) -> a -> b
$ DynamicWriterT t w m (v' a) -> m (v' a, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT (DynamicWriterT t w m (v' a) -> m (v' a, Dynamic t w))
-> DynamicWriterT t w m (v' a) -> m (v' a, Dynamic t w)
forall a b. (a -> b) -> a -> b
$ k a -> v a -> DynamicWriterT t w m (v' a)
forall a. k a -> v a -> DynamicWriterT t w m (v' a)
f k a
k v a
v) DMap k v
dm0 Event t (p k v)
dm'
let getValue :: DynamicWriterTLoweredResult t w v a -> v a
getValue (DynamicWriterTLoweredResult (v :: v a
v, _)) = v a
v
getWritten :: DynamicWriterTLoweredResult t w v a -> Dynamic t w
getWritten (DynamicWriterTLoweredResult (_, w :: Dynamic t w
w)) = Dynamic t w
w
liftedResult0 :: DMap k v'
liftedResult0 = (forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> DMap k (DynamicWriterTLoweredResult t w 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 forall a. DynamicWriterTLoweredResult t w v' a -> v' a
forall t w (v :: * -> *) a.
DynamicWriterTLoweredResult t w v a -> v a
getValue DMap k (DynamicWriterTLoweredResult t w v')
result0
liftedResult' :: Event t (p k v')
liftedResult' = Event t (p k (DynamicWriterTLoweredResult t w v'))
-> (p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> Event t (p k v')
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
ffor Event t (p k (DynamicWriterTLoweredResult t w v'))
result' ((p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> Event t (p k v'))
-> (p k (DynamicWriterTLoweredResult t w v') -> p k v')
-> Event t (p k v')
forall a b. (a -> b) -> a -> b
$ (forall a. DynamicWriterTLoweredResult t w v' a -> v' a)
-> p k (DynamicWriterTLoweredResult t w v') -> p k v'
mapPatch forall a. DynamicWriterTLoweredResult t w v' a -> v' a
forall t w (v :: * -> *) a.
DynamicWriterTLoweredResult t w v a -> v a
getValue
liftedWritten0 :: Map (Some k) (Dynamic t w)
liftedWritten0 :: Map (Some k) (Dynamic t w)
liftedWritten0 = (forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> DMap k (DynamicWriterTLoweredResult t w v')
-> Map (Some k) (Dynamic t w)
forall k1 (v :: k1 -> *) v' (k2 :: k1 -> *).
(forall (a :: k1). v a -> v') -> DMap k2 v -> Map (Some k2) v'
weakenDMapWith forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w
forall t w (v :: * -> *) a.
DynamicWriterTLoweredResult t w v a -> Dynamic t w
getWritten DMap k (DynamicWriterTLoweredResult t w v')
result0
liftedWritten' :: Event t (p' (Some k) (Dynamic t w))
liftedWritten' = Event t (p k (DynamicWriterTLoweredResult t w v'))
-> (p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> Event t (p' (Some k) (Dynamic t w))
forall (f :: * -> *) a b. Functor f => f a -> (a -> b) -> f b
ffor Event t (p k (DynamicWriterTLoweredResult t w v'))
result' ((p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> Event t (p' (Some k) (Dynamic t w)))
-> (p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w))
-> Event t (p' (Some k) (Dynamic t w))
forall a b. (a -> b) -> a -> b
$ (forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w)
-> p k (DynamicWriterTLoweredResult t w v')
-> p' (Some k) (Dynamic t w)
weakenPatchWith forall a. DynamicWriterTLoweredResult t w v' a -> Dynamic t w
forall t w (v :: * -> *) a.
DynamicWriterTLoweredResult t w v a -> Dynamic t w
getWritten
Incremental t (p' (Some k) (Dynamic t w))
i <- PatchTarget (p' (Some k) (Dynamic t w))
-> Event t (p' (Some k) (Dynamic t w))
-> DynamicWriterT t w m (Incremental t (p' (Some k) (Dynamic t w)))
forall k (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental Map (Some k) (Dynamic t w)
PatchTarget (p' (Some k) (Dynamic t w))
liftedWritten0 Event t (p' (Some k) (Dynamic t w))
liftedWritten'
Dynamic t w -> DynamicWriterT t w m ()
forall t w (m :: * -> *).
DynamicWriter t w m =>
Dynamic t w -> m ()
tellDyn (Dynamic t w -> DynamicWriterT t w m ())
-> Dynamic t w -> DynamicWriterT t w m ()
forall a b. (a -> b) -> a -> b
$ (Map (Some k) w -> w) -> Dynamic t (Map (Some k) w) -> Dynamic t w
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([w] -> w
forall a. Monoid a => [a] -> a
mconcat ([w] -> w) -> (Map (Some k) w -> [w]) -> Map (Some k) w -> w
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Map (Some k) w -> [w]
forall k a. Map k a -> [a]
Map.elems) (Dynamic t (Map (Some k) w) -> Dynamic t w)
-> Dynamic t (Map (Some k) w) -> Dynamic t w
forall a b. (a -> b) -> a -> b
$ Incremental t (p' (Some k) w) -> Dynamic t (Map (Some k) w)
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Dynamic t (PatchTarget p)
incrementalToDynamic (Incremental t (p' (Some k) w) -> Dynamic t (Map (Some k) w))
-> Incremental t (p' (Some k) w) -> Dynamic t (Map (Some k) w)
forall a b. (a -> b) -> a -> b
$ Incremental t (p' (Some k) (Dynamic t w))
-> Incremental t (p' (Some k) w)
mergeMyDynIncremental Incremental t (p' (Some k) (Dynamic t w))
i
(DMap k v', Event t (p k v'))
-> DynamicWriterT t w m (DMap k v', Event t (p k v'))
forall (m :: * -> *) a. Monad m => a -> m a
return (DMap k v'
liftedResult0, Event t (p k v')
liftedResult')
traverseIntMapWithKeyWithAdjustImpl :: forall t w v' p p' v m. (PatchTarget (p' (Dynamic t w)) ~ IntMap (Dynamic t w), PatchTarget (p' w) ~ IntMap w, Patch (p' w), Patch (p' (Dynamic t w)), MonadFix m, Monoid w, Reflex t, MonadHold t m, Functor p, p ~ p')
=> ( (IntMap.Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (p v)
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
)
-> (Incremental t (p' (Dynamic t w)) -> Incremental t (p' w))
-> (IntMap.Key -> v -> DynamicWriterT t w m v')
-> IntMap v
-> Event t (p v)
-> DynamicWriterT t w m (IntMap v', Event t (p v'))
traverseIntMapWithKeyWithAdjustImpl :: ((Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (p v)
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w))))
-> (Incremental t (p' (Dynamic t w)) -> Incremental t (p' w))
-> (Key -> v -> DynamicWriterT t w m v')
-> IntMap v
-> Event t (p v)
-> DynamicWriterT t w m (IntMap v', Event t (p v'))
traverseIntMapWithKeyWithAdjustImpl base :: (Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (p v)
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
base mergeMyDynIncremental :: Incremental t (p' (Dynamic t w)) -> Incremental t (p' w)
mergeMyDynIncremental f :: Key -> v -> DynamicWriterT t w m v'
f (IntMap v
dm0 :: IntMap v) dm' :: Event t (p v)
dm' = do
(result0 :: IntMap (v', Dynamic t w)
result0, result' :: Event t (p (v', Dynamic t w))
result') <- m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
-> DynamicWriterT
t w m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
-> DynamicWriterT
t w m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w))))
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
-> DynamicWriterT
t w m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
forall a b. (a -> b) -> a -> b
$ (Key -> v -> m (v', Dynamic t w))
-> IntMap v
-> Event t (p v)
-> m (IntMap (v', Dynamic t w), Event t (p (v', Dynamic t w)))
base (\k :: Key
k v :: v
v -> DynamicWriterT t w m v' -> m (v', Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT (DynamicWriterT t w m v' -> m (v', Dynamic t w))
-> DynamicWriterT t w m v' -> m (v', Dynamic t w)
forall a b. (a -> b) -> a -> b
$ Key -> v -> DynamicWriterT t w m v'
f Key
k v
v) IntMap v
dm0 Event t (p v)
dm'
let liftedResult0 :: IntMap v'
liftedResult0 = ((v', Dynamic t w) -> v') -> IntMap (v', Dynamic t w) -> IntMap v'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v', Dynamic t w) -> v'
forall a b. (a, b) -> a
fst IntMap (v', Dynamic t w)
result0
liftedResult' :: Event t (p v')
liftedResult' = (p (v', Dynamic t w) -> p v')
-> Event t (p (v', Dynamic t w)) -> Event t (p v')
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((v', Dynamic t w) -> v') -> p (v', Dynamic t w) -> p v'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v', Dynamic t w) -> v'
forall a b. (a, b) -> a
fst) Event t (p (v', Dynamic t w))
result'
liftedWritten0 :: IntMap (Dynamic t w)
liftedWritten0 :: IntMap (Dynamic t w)
liftedWritten0 = ((v', Dynamic t w) -> Dynamic t w)
-> IntMap (v', Dynamic t w) -> IntMap (Dynamic t w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v', Dynamic t w) -> Dynamic t w
forall a b. (a, b) -> b
snd IntMap (v', Dynamic t w)
result0
liftedWritten' :: Event t (p (Dynamic t w))
liftedWritten' = (p (v', Dynamic t w) -> p (Dynamic t w))
-> Event t (p (v', Dynamic t w)) -> Event t (p (Dynamic t w))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((v', Dynamic t w) -> Dynamic t w)
-> p (v', Dynamic t w) -> p (Dynamic t w)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (v', Dynamic t w) -> Dynamic t w
forall a b. (a, b) -> b
snd) Event t (p (v', Dynamic t w))
result'
Incremental t (p (Dynamic t w))
i <- PatchTarget (p (Dynamic t w))
-> Event t (p (Dynamic t w))
-> DynamicWriterT t w m (Incremental t (p (Dynamic t w)))
forall k (t :: k) (m :: * -> *) p.
(MonadHold t m, Patch p) =>
PatchTarget p -> Event t p -> m (Incremental t p)
holdIncremental IntMap (Dynamic t w)
PatchTarget (p (Dynamic t w))
liftedWritten0 Event t (p (Dynamic t w))
liftedWritten'
Dynamic t w -> DynamicWriterT t w m ()
forall t w (m :: * -> *).
DynamicWriter t w m =>
Dynamic t w -> m ()
tellDyn (Dynamic t w -> DynamicWriterT t w m ())
-> Dynamic t w -> DynamicWriterT t w m ()
forall a b. (a -> b) -> a -> b
$ (IntMap w -> w) -> Dynamic t (IntMap w) -> Dynamic t w
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ([w] -> w
forall a. Monoid a => [a] -> a
mconcat ([w] -> w) -> (IntMap w -> [w]) -> IntMap w -> w
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IntMap w -> [w]
forall a. IntMap a -> [a]
IntMap.elems) (Dynamic t (IntMap w) -> Dynamic t w)
-> Dynamic t (IntMap w) -> Dynamic t w
forall a b. (a -> b) -> a -> b
$ Incremental t (p' w) -> Dynamic t (IntMap w)
forall k (t :: k) p.
(Reflex t, Patch p) =>
Incremental t p -> Dynamic t (PatchTarget p)
incrementalToDynamic (Incremental t (p' w) -> Dynamic t (IntMap w))
-> Incremental t (p' w) -> Dynamic t (IntMap w)
forall a b. (a -> b) -> a -> b
$ Incremental t (p' (Dynamic t w)) -> Incremental t (p' w)
mergeMyDynIncremental Incremental t (p (Dynamic t w))
Incremental t (p' (Dynamic t w))
i
(IntMap v', Event t (p v'))
-> DynamicWriterT t w m (IntMap v', Event t (p v'))
forall (m :: * -> *) a. Monad m => a -> m a
return (IntMap v'
liftedResult0, Event t (p v')
liftedResult')
withDynamicWriterT :: (Monoid w, Monoid w', Reflex t, MonadHold t m, MonadFix m)
=> (w -> w')
-> DynamicWriterT t w m a
-> DynamicWriterT t w' m a
withDynamicWriterT :: (w -> w') -> DynamicWriterT t w m a -> DynamicWriterT t w' m a
withDynamicWriterT f :: w -> w'
f dw :: DynamicWriterT t w m a
dw = do
(r :: a
r, d :: Dynamic t w'
d) <- m (a, Dynamic t w') -> DynamicWriterT t w' m (a, Dynamic t w')
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (a, Dynamic t w') -> DynamicWriterT t w' m (a, Dynamic t w'))
-> m (a, Dynamic t w') -> DynamicWriterT t w' m (a, Dynamic t w')
forall a b. (a -> b) -> a -> b
$ do
(r :: a
r, d :: Dynamic t w
d) <- DynamicWriterT t w m a -> m (a, Dynamic t w)
forall (m :: * -> *) t w a.
(MonadFix m, Reflex t, Monoid w) =>
DynamicWriterT t w m a -> m (a, Dynamic t w)
runDynamicWriterT DynamicWriterT t w m a
dw
let d' :: Dynamic t w'
d' = (w -> w') -> Dynamic t w -> Dynamic t w'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap w -> w'
f Dynamic t w
d
(a, Dynamic t w') -> m (a, Dynamic t w')
forall (m :: * -> *) a. Monad m => a -> m a
return (a
r, Dynamic t w'
d')
Dynamic t w' -> DynamicWriterT t w' m ()
forall t w (m :: * -> *).
DynamicWriter t w m =>
Dynamic t w -> m ()
tellDyn Dynamic t w'
d
a -> DynamicWriterT t w' m a
forall (m :: * -> *) a. Monad m => a -> m a
return a
r
instance Requester t m => Requester t (DynamicWriterT t w m) where
type Request (DynamicWriterT t w m) = Request m
type Response (DynamicWriterT t w m) = Response m
requesting :: Event t (Request (DynamicWriterT t w m) a)
-> DynamicWriterT
t w m (Event t (Response (DynamicWriterT t w m) a))
requesting = m (Event t (Response m a))
-> DynamicWriterT t w m (Event t (Response m a))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Event t (Response m a))
-> DynamicWriterT t w m (Event t (Response m a)))
-> (Event t (Request m a) -> m (Event t (Response m a)))
-> Event t (Request m a)
-> DynamicWriterT t w m (Event t (Response m a))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Request m a) -> m (Event t (Response m a))
forall t (m :: * -> *) a.
Requester t m =>
Event t (Request m a) -> m (Event t (Response m a))
requesting
requesting_ :: Event t (Request (DynamicWriterT t w m) a)
-> DynamicWriterT t w m ()
requesting_ = m () -> DynamicWriterT t w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t w m ())
-> (Event t (Request m a) -> m ())
-> Event t (Request m a)
-> DynamicWriterT t w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Event t (Request m a) -> m ()
forall t (m :: * -> *) a.
Requester t m =>
Event t (Request m a) -> m ()
requesting_
instance (MonadQuery t q m, Monad m) => MonadQuery t q (DynamicWriterT t w m) where
tellQueryIncremental :: Incremental t (AdditivePatch q) -> DynamicWriterT t w m ()
tellQueryIncremental = m () -> DynamicWriterT t w m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t w m ())
-> (Incremental t (AdditivePatch q) -> m ())
-> Incremental t (AdditivePatch q)
-> DynamicWriterT t w m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Incremental t (AdditivePatch q) -> m ()
forall t q (m :: * -> *).
MonadQuery t q m =>
Incremental t (AdditivePatch q) -> m ()
tellQueryIncremental
askQueryResult :: DynamicWriterT t w m (Dynamic t (QueryResult q))
askQueryResult = m (Dynamic t (QueryResult q))
-> DynamicWriterT t w m (Dynamic t (QueryResult q))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift m (Dynamic t (QueryResult q))
forall t q (m :: * -> *).
MonadQuery t q m =>
m (Dynamic t (QueryResult q))
askQueryResult
queryIncremental :: Incremental t (AdditivePatch q)
-> DynamicWriterT t w m (Dynamic t (QueryResult q))
queryIncremental = m (Dynamic t (QueryResult q))
-> DynamicWriterT t w m (Dynamic t (QueryResult q))
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m (Dynamic t (QueryResult q))
-> DynamicWriterT t w m (Dynamic t (QueryResult q)))
-> (Incremental t (AdditivePatch q)
-> m (Dynamic t (QueryResult q)))
-> Incremental t (AdditivePatch q)
-> DynamicWriterT t w m (Dynamic t (QueryResult q))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Incremental t (AdditivePatch q) -> m (Dynamic t (QueryResult q))
forall t q (m :: * -> *).
MonadQuery t q m =>
Incremental t (AdditivePatch q) -> m (Dynamic t (QueryResult q))
queryIncremental
instance EventWriter t w m => EventWriter t w (DynamicWriterT t v m) where
tellEvent :: Event t w -> DynamicWriterT t v m ()
tellEvent = m () -> DynamicWriterT t v m ()
forall (t :: (* -> *) -> * -> *) (m :: * -> *) a.
(MonadTrans t, Monad m) =>
m a -> t m a
lift (m () -> DynamicWriterT t v m ())
-> (Event t w -> m ()) -> Event t w -> DynamicWriterT t v 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