on develop help sign in
Add mapQueryT
196cb7eAli Abrar
src/Reflex/Query/Base.hs+5
@@ -17,6 +17,7 @@ module Reflex.Query.Base
17 , mapQueryResult
17 , mapQueryResult
18 , dynWithQueryT
18 , dynWithQueryT
19 , withQueryT
19 , withQueryT
20+ , mapQueryT
20 ) where
21 ) where
21
22
22import Control.Applicative (liftA2)
23import Control.Applicative (liftA2)
@@ -289,6 +290,10 @@ withQueryT f a = do
289 (fmapCheap (AdditivePatch . mapQuery f . unAdditivePatch) $ updatedIncremental q)
290 (fmapCheap (AdditivePatch . mapQuery f . unAdditivePatch) $ updatedIncremental q)
290 return result
291 return result
291
292
293+-- | Maps a function over a 'QueryT' that can change the underlying monad
294+mapQueryT :: (forall b. m b -> n b) -> QueryT t q m a -> QueryT t q n a
295+mapQueryT f (QueryT a) = QueryT $ mapStateT (mapEventWriterT (mapReaderT f)) a
296+
292-- | dynWithQueryT's (Dynamic t QueryMorphism) argument needs to be a group homomorphism at all times in order to behave correctly
297-- | dynWithQueryT's (Dynamic t QueryMorphism) argument needs to be a group homomorphism at all times in order to behave correctly
293dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
298dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
294 => Dynamic t (QueryMorphism q q')
299 => Dynamic t (QueryMorphism q q')