Skip to content

Commit 25b2155

Browse files
authored
Merge branch 'develop' into extra-query-instances
2 parents 57e0a1c + 02d2cef commit 25b2155

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

ChangeLog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ module Reflex.Query.Base
1616
, mapQueryResult
1717
, dynWithQueryT
1818
, withQueryT
19+
, mapQueryT
1920
) where
2021

2122
import 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
291296
dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
292297
=> Dynamic t (QueryMorphism q q')

0 commit comments

Comments
 (0)