on develop help sign in
Add mapQueryT
commit196cb7e1666b12acb457fa1f129b9f55dc924e3a authorAli Abrar <aliabrar@gmail.com> dateTue 21 May 2019, 12:32 (7 years ago) parent7f42217
1 file changed+5
src/Reflex/Query/Base.hs+5
src/Reflex/Query/Base.hs+5
@@ -17,6 +17,7 @@ module Reflex.Query.Base
1717 , mapQueryResult
1818 , dynWithQueryT
1919 , withQueryT
20+ , mapQueryT
2021 ) where
2122
2223import Control.Applicative (liftA2)
@@ -289,6 +290,10 @@ withQueryT f a = do
289290 (fmapCheap (AdditivePatch . mapQuery f . unAdditivePatch) $ updatedIncremental q)
290291 return result
291292
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+
292297-- | dynWithQueryT's (Dynamic t QueryMorphism) argument needs to be a group homomorphism at all times in order to behave correctly
293298dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
294299 => Dynamic t (QueryMorphism q q')