on develop help sign in
Add mapQueryT

(cherry picked from commit 196cb7e1666b12acb457fa1f129b9f55dc924e3a + changelog)

commit72ec2a9166192ed8d3441f58da78d647c8e3cdba authorAli Abrar <aliabrar@gmail.com> dateTue 21 May 2019, 12:32 (7 years ago) parentfd38931
2 files changed+9
ChangeLog.md+4 src/Reflex/Query/Base.hs+5
ChangeLog.md+4
@@ -1,5 +1,9 @@
11# Revision history for reflex
22
3+## Unreleased
4+
5+* Add `Reflex.Query.Base.mapQueryT`. See that module for documentation
6+
37## 0.6.3
48
59* `Data.WeakBag.traverse` and `Data.FastWeakBag.traverse` have been deprecated.
src/Reflex/Query/Base.hs+5
@@ -16,6 +16,7 @@ module Reflex.Query.Base
1616 , mapQueryResult
1717 , dynWithQueryT
1818 , withQueryT
19+ , mapQueryT
1920 ) where
2021
2122import Control.Applicative (liftA2)
@@ -287,6 +288,10 @@ withQueryT f a = do
287288 (fmapCheap (AdditivePatch . mapQuery f . unAdditivePatch) $ updatedIncremental q)
288289 return result
289290
291+-- | Maps a function over a 'QueryT' that can change the underlying monad
292+mapQueryT :: (forall b. m b -> n b) -> QueryT t q m a -> QueryT t q n a
293+mapQueryT f (QueryT a) = QueryT $ mapStateT (mapEventWriterT (mapReaderT f)) a
294+
290295-- | dynWithQueryT's (Dynamic t QueryMorphism) argument needs to be a group homomorphism at all times in order to behave correctly
291296dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
292297 => Dynamic t (QueryMorphism q q')