@@ -55,12 +55,10 @@ instance (Ord k, Query v) => Query (MonoidalMap k v) where
55 type QueryResult (MonoidalMap k v) = MonoidalMap k (QueryResult v)
55 type QueryResult (MonoidalMap k v) = MonoidalMap k (QueryResult v)
56 crop q r = MonoidalMap.intersectionWith (flip crop) r q
56 crop q r = MonoidalMap.intersectionWith (flip crop) r q
58−-- asking two questions is the same as asking both questions.
59instance (Query a, Query b) => Query (a, b) where
58instance (Query a, Query b) => Query (a, b) where
60 type QueryResult (a, b) = (QueryResult a, QueryResult b)
59 type QueryResult (a, b) = (QueryResult a, QueryResult b)
61 crop (x, x') (y, y') = (crop x y, crop x' y')
60 crop (x, x') (y, y') = (crop x y, crop x' y')
63−-- ¯\_(゚ヮ゚)_/¯ ¯\_(ツ)_/¯
64instance Query () where
62instance Query () where
65 type QueryResult () = ()
63 type QueryResult () = ()
66 crop _ _ = ()
64 crop _ _ = ()
@@ -143,7 +141,7 @@ queryDyn q = do
143 tellQueryDyn q
141 tellQueryDyn q
144 zipDynWith crop q <$> askQueryResult
142 zipDynWith crop q <$> askQueryResult
146−-- | We can already say this in reflex
144+-- | use a query morphism to operate on a smaller version of a query.
147subQuery :: (Reflex t, MonadQuery t q2 m, Monad m) => QueryMorphism q1 q2 -> Dynamic t q1 -> m (Dynamic t (QueryResult q1))
145subQuery :: (Reflex t, MonadQuery t q2 m, Monad m) => QueryMorphism q1 q2 -> Dynamic t q1 -> m (Dynamic t (QueryResult q1))
148subQuery (QueryMorphism f g) x = fmap g <$> queryDyn (fmap f x)
146subQuery (QueryMorphism f g) x = fmap g <$> queryDyn (fmap f x)