Add mapQueryT

(cherry picked from commit 196cb7e166 +
changelog)
This commit is contained in:
Ali Abrar 2019-05-21 12:32:31 -04:00 committed by John Ericson
parent fd38931431
commit 72ec2a9166
2 changed files with 9 additions and 0 deletions

View File

@ -1,5 +1,9 @@
# Revision history for reflex
## Unreleased
* Add `Reflex.Query.Base.mapQueryT`. See that module for documentation
## 0.6.3
* `Data.WeakBag.traverse` and `Data.FastWeakBag.traverse` have been deprecated.

View File

@ -16,6 +16,7 @@ module Reflex.Query.Base
, mapQueryResult
, dynWithQueryT
, withQueryT
, mapQueryT
) where
import Control.Applicative (liftA2)
@ -287,6 +288,10 @@ withQueryT f a = do
(fmapCheap (AdditivePatch . mapQuery f . unAdditivePatch) $ updatedIncremental q)
return result
-- | Maps a function over a 'QueryT' that can change the underlying monad
mapQueryT :: (forall b. m b -> n b) -> QueryT t q m a -> QueryT t q n a
mapQueryT f (QueryT a) = QueryT $ mapStateT (mapEventWriterT (mapReaderT f)) a
-- | dynWithQueryT's (Dynamic t QueryMorphism) argument needs to be a group homomorphism at all times in order to behave correctly
dynWithQueryT :: (MonadFix m, PostBuild t m, Group q, Additive q, Group q', Additive q', Query q')
=> Dynamic t (QueryMorphism q q')