on develop help sign in
Some more random cleanups
677ce27Ryan Trinkle
reflex.cabal+5
@@ -144,6 +144,7 @@ library
144 Reflex.Workflow
144 Reflex.Workflow
145
145
146 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs -funbox-strict-fields -O2 -fspecialise-aggressively
146 ghc-options: -Wall -fwarn-redundant-constraints -fwarn-tabs -funbox-strict-fields -O2 -fspecialise-aggressively
147+ ghc-prof-options: -fprof-auto-calls
147
148
148 if flag(debug-trace-events)
149 if flag(debug-trace-events)
149 cpp-options: -DDEBUG_TRACE_EVENTS
150 cpp-options: -DDEBUG_TRACE_EVENTS
@@ -179,6 +180,7 @@ test-suite semantics
179 main-is: semantics.hs
180 main-is: semantics.hs
180 hs-source-dirs: test
181 hs-source-dirs: test
181 ghc-options: -O2 -Wall -rtsopts
182 ghc-options: -O2 -Wall -rtsopts
183+ ghc-prof-options: -fprof-auto-calls
182 build-depends:
184 build-depends:
183 base,
185 base,
184 bifunctors,
186 bifunctors,
@@ -204,6 +206,7 @@ test-suite CrossImpl
204 main-is: Reflex/Test/CrossImpl.hs
206 main-is: Reflex/Test/CrossImpl.hs
205 hs-source-dirs: test
207 hs-source-dirs: test
206 ghc-options: -O2 -Wall -rtsopts
208 ghc-options: -O2 -Wall -rtsopts
209+ ghc-prof-options: -fprof-auto-calls
207 build-depends:
210 build-depends:
208 base,
211 base,
209 containers,
212 containers,
@@ -356,6 +359,7 @@ benchmark spider-bench
356 hs-source-dirs: bench test
359 hs-source-dirs: bench test
357 main-is: Main.hs
360 main-is: Main.hs
358 ghc-options: -Wall -O2 -rtsopts
361 ghc-options: -Wall -O2 -rtsopts
362+ ghc-prof-options: -fprof-auto-calls
359 build-depends:
363 build-depends:
360 base,
364 base,
361 containers,
365 containers,
@@ -381,6 +385,7 @@ benchmark saulzar-bench
381 c-sources: bench-cbits/checkCapability.c
385 c-sources: bench-cbits/checkCapability.c
382 main-is: RunAll.hs
386 main-is: RunAll.hs
383 ghc-options: -Wall -O2 -rtsopts -threaded
387 ghc-options: -Wall -O2 -rtsopts -threaded
388+ ghc-prof-options: -fprof-auto-calls
384 build-depends:
389 build-depends:
385 base,
390 base,
386 containers,
391 containers,
src/Reflex/Class.hs+16−13
@@ -944,10 +944,6 @@ unsafeMapIncremental f g a = unsafeBuildIncremental (fmap f $ sample $ currentIn
944mergeMap :: (Reflex t, Ord k) => Map k (Event t a) -> Event t (Map k a)
944mergeMap :: (Reflex t, Ord k) => Map k (Event t a) -> Event t (Map k a)
945mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
945mergeMap = fmap dmapToMap . merge . mapWithFunctorToDMap
946
946
947−-- | Like 'mergeMap' but for 'IntMap'.
948−mergeIntMap :: Reflex t => IntMap (Event t a) -> Event t (IntMap a)
949−mergeIntMap = fmap dmapToIntMap . merge . intMapWithFunctorToDMap
950−
951-- | Create a merge whose parents can change over time
947-- | Create a merge whose parents can change over time
952mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) -> Event t (Map k a)
948mergeMapIncremental :: (Reflex t, Ord k) => Incremental t (PatchMap k (Event t a)) -> Event t (Map k a)
953mergeMapIncremental = fmap dmapToMap . mergeIncremental . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWith id)
949mergeMapIncremental = fmap dmapToMap . mergeIncremental . unsafeMapIncremental mapWithFunctorToDMap (const2PatchDMapWith id)
@@ -1032,19 +1028,19 @@ switchHoldPromptOnly e0 e' = do
1032
1028
1033-- | When the given outer event fires, condense the inner events into the contained patch. Non-firing inner events will be replaced with deletions.
1029-- | When the given outer event fires, condense the inner events into the contained patch. Non-firing inner events will be replaced with deletions.
1034coincidencePatchMap :: (Reflex t, Ord k) => Event t (PatchMap k (Event t v)) -> Event t (PatchMap k v)
1030coincidencePatchMap :: (Reflex t, Ord k) => Event t (PatchMap k (Event t v)) -> Event t (PatchMap k v)
1035−coincidencePatchMap e = fmapCheap PatchMap $ coincidence $ ffor e $ \(PatchMap m) -> mergeMap $ ffor m $ \case
1031+coincidencePatchMap e = fmapCheap PatchMap $ coincidence $ fforCheap e $ \(PatchMap m) -> mergeMap $ ffor m $ \case
1036 Nothing -> fmapCheap (const Nothing) e
1032 Nothing -> fmapCheap (const Nothing) e
1037 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
1033 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
1038
1034
1039-- | See 'coincidencePatchMap'
1035-- | See 'coincidencePatchMap'
1040coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) -> Event t (PatchIntMap v)
1036coincidencePatchIntMap :: Reflex t => Event t (PatchIntMap (Event t v)) -> Event t (PatchIntMap v)
1041−coincidencePatchIntMap e = fmapCheap PatchIntMap $ coincidence $ ffor e $ \(PatchIntMap m) -> mergeIntMap $ ffor m $ \case
1037+coincidencePatchIntMap e = fmapCheap PatchIntMap $ coincidence $ fforCheap e $ \(PatchIntMap m) -> mergeIntMap $ ffor m $ \case
1042 Nothing -> fmapCheap (const Nothing) e
1038 Nothing -> fmapCheap (const Nothing) e
1043 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
1039 Just ev -> leftmost [fmapCheap Just ev, fmapCheap (const Nothing) e]
1044
1040
1045-- | See 'coincidencePatchMap'
1041-- | See 'coincidencePatchMap'
1046coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) -> Event t (PatchMapWithMove k v)
1042coincidencePatchMapWithMove :: (Reflex t, Ord k) => Event t (PatchMapWithMove k (Event t v)) -> Event t (PatchMapWithMove k v)
1047−coincidencePatchMapWithMove e = fmapCheap unsafePatchMapWithMove $ coincidence $ ffor e $ \p -> mergeMap $ ffor (unPatchMapWithMove p) $ \ni -> case PatchMapWithMove._nodeInfo_from ni of
1043+coincidencePatchMapWithMove e = fmapCheap unsafePatchMapWithMove $ coincidence $ fforCheap e $ \p -> mergeMap $ ffor (unPatchMapWithMove p) $ \ni -> case PatchMapWithMove._nodeInfo_from ni of
1048 PatchMapWithMove.From_Delete -> fforCheap e $ \_ ->
1044 PatchMapWithMove.From_Delete -> fforCheap e $ \_ ->
1049 ni { PatchMapWithMove._nodeInfo_from = PatchMapWithMove.From_Delete }
1045 ni { PatchMapWithMove._nodeInfo_from = PatchMapWithMove.From_Delete }
1050 PatchMapWithMove.From_Move k -> fforCheap e $ \_ ->
1046 PatchMapWithMove.From_Move k -> fforCheap e $ \_ ->
@@ -1304,7 +1300,7 @@ accumMaybeMDyn
1304 -> Event t b
1300 -> Event t b
1305 -> m (Dynamic t a)
1301 -> m (Dynamic t a)
1306accumMaybeMDyn f z e = do
1302accumMaybeMDyn f z e = do
1307− rec let e' = flip push e $ \o -> do
1303+ rec let e' = flip pushCheap e $ \o -> do
1308 v <- sample $ current d'
1304 v <- sample $ current d'
1309 f v o
1305 f v o
1310 d' <- holdDyn z e'
1306 d' <- holdDyn z e'
@@ -1360,8 +1356,8 @@ mapAccumMaybeMDyn f z e = do
1360 return $ case result of
1356 return $ case result of
1361 (Nothing, Nothing) -> Nothing
1357 (Nothing, Nothing) -> Nothing
1362 _ -> Just result
1358 _ -> Just result
1363− d' <- holdDyn z $ mapMaybe fst e'
1359+ d' <- holdDyn z $ fmapMaybeCheap fst e'
1364− return (d', mapMaybe snd e')
1360+ return (d', fmapMaybeCheap snd e')
1365
1361
1366-- | Accumulate a 'Behavior' by folding occurrences of an 'Event'
1362-- | Accumulate a 'Behavior' by folding occurrences of an 'Event'
1367-- with the provided function.
1363-- with the provided function.
@@ -1399,7 +1395,7 @@ accumMaybeB f = accumMaybeMB $ \v o -> return $ f v o
1399{-# INLINE accumMaybeMB #-}
1395{-# INLINE accumMaybeMB #-}
1400accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a)
1396accumMaybeMB :: (Reflex t, MonadHold t m, MonadFix m) => (a -> b -> PushM t (Maybe a)) -> a -> Event t b -> m (Behavior t a)
1401accumMaybeMB f z e = do
1397accumMaybeMB f z e = do
1402− rec let e' = flip push e $ \o -> do
1398+ rec let e' = flip pushCheap e $ \o -> do
1403 v <- sample d'
1399 v <- sample d'
1404 f v o
1400 f v o
1405 d' <- hold z e'
1401 d' <- hold z e'
@@ -1449,8 +1445,8 @@ mapAccumMaybeMB f z e = do
1449 return $ case result of
1445 return $ case result of
1450 (Nothing, Nothing) -> Nothing
1446 (Nothing, Nothing) -> Nothing
1451 _ -> Just result
1447 _ -> Just result
1452− d' <- hold z $ mapMaybe fst e'
1448+ d' <- hold z $ fmapMaybeCheap fst e'
1453− return (d', mapMaybe snd e')
1449+ return (d', fmapMaybeCheap snd e')
1454
1450
1455-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1451-- | Accumulate occurrences of an 'Event', producing an output occurrence each
1456-- time. Discard the underlying 'Accumulator'.
1452-- time. Discard the underlying 'Accumulator'.
@@ -1676,7 +1672,14 @@ mergeWithFoldCheap' f es =
1676-- | See 'switchHoldPromptly'
1672-- | See 'switchHoldPromptly'
1677switchPromptly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
1673switchPromptly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
1678switchPromptly = switchHoldPromptly
1674switchPromptly = switchHoldPromptly
1675+
1679{-# DEPRECATED switchPromptOnly "Use 'switchHoldPromptOnly' instead. The 'switchHold*' naming convention was chosen because those functions are more closely related to each other than they are to 'switch'. " #-}
1676{-# DEPRECATED switchPromptOnly "Use 'switchHoldPromptOnly' instead. The 'switchHold*' naming convention was chosen because those functions are more closely related to each other than they are to 'switch'. " #-}
1680-- | See 'switchHoldPromptOnly'
1677-- | See 'switchHoldPromptOnly'
1681switchPromptOnly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
1678switchPromptOnly :: (Reflex t, MonadHold t m) => Event t a -> Event t (Event t a) -> m (Event t a)
1682switchPromptOnly = switchHoldPromptOnly
1679switchPromptOnly = switchHoldPromptOnly
1680+
1681+{-# DEPRECATED mergeIntMap "Use 'mergeInt' instead" #-}
1682+-- | Like 'mergeMap' but for 'IntMap'.
1683+mergeIntMap :: Reflex t => IntMap (Event t a) -> Event t (IntMap a)
1684+mergeIntMap = mergeInt
1685+
src/Reflex/PerformEvent/Base.hs+3−3
@@ -110,7 +110,7 @@ instance (ReflexHost t, PrimMonad (HostFrame t)) => Adjustable t (PerformEventT
110 requests0 = fmap snd children0
110 requests0 = fmap snd children0
111 results' = fmap fst <$> children'
111 results' = fmap fst <$> children'
112 requests' = fmap snd `fmapCheap` children'
112 requests' = fmap snd `fmapCheap` children'
113− requests <- switchHoldPromptOnlyIncremental mergeIntIncremental coincidencePatchIntMap requests0 $ requests'
113+ requests <- switchHoldPromptOnlyIncremental mergeIntIncremental coincidencePatchIntMap requests0 requests'
114 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
114 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
115 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatIntMapMaybe
115 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatIntMapMaybe
116 pure (results0, results')
116 pure (results0, results')
@@ -125,7 +125,7 @@ instance (ReflexHost t, PrimMonad (HostFrame t)) => Adjustable t (PerformEventT
125 requests0 = weakenDMapWith (fst . getCompose) children0
125 requests0 = weakenDMapWith (fst . getCompose) children0
126 results' = mapPatchDMap (snd . getCompose) <$> children'
126 results' = mapPatchDMap (snd . getCompose) <$> children'
127 requests' = weakenPatchDMapWith (fst . getCompose) `fmapCheap` children'
127 requests' = weakenPatchDMapWith (fst . getCompose) `fmapCheap` children'
128− requests <- switchHoldPromptOnlyIncremental mergeMapIncremental coincidencePatchMap requests0 $ requests'
128+ requests <- switchHoldPromptOnlyIncremental mergeMapIncremental coincidencePatchMap requests0 requests'
129 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
129 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
130 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatMapMaybe
130 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatMapMaybe
131 pure (results0, results')
131 pure (results0, results')
@@ -140,7 +140,7 @@ instance (ReflexHost t, PrimMonad (HostFrame t)) => Adjustable t (PerformEventT
140 requests0 = weakenDMapWith (fst . getCompose) children0
140 requests0 = weakenDMapWith (fst . getCompose) children0
141 results' = mapPatchDMapWithMove (snd . getCompose) <$> children'
141 results' = mapPatchDMapWithMove (snd . getCompose) <$> children'
142 requests' = weakenPatchDMapWithMoveWith (fst . getCompose) `fmapCheap` children'
142 requests' = weakenPatchDMapWithMoveWith (fst . getCompose) `fmapCheap` children'
143− requests <- switchHoldPromptOnlyIncremental mergeMapIncrementalWithMove coincidencePatchMapWithMove requests0 $ requests'
143+ requests <- switchHoldPromptOnlyIncremental mergeMapIncrementalWithMove coincidencePatchMapWithMove requests0 requests'
144 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
144 --TODO: promptly *prevent* events, then sign up the new ones; this is a serious breaking change to PerformEvent
145 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatMapMaybe
145 RequesterInternalT $ tellEvent $ fforMaybeCheap requests concatMapMaybe
146 pure (results0, results')
146 pure (results0, results')
src/Reflex/Requester/Base/Internal.hs−6
@@ -68,12 +68,6 @@ import Data.Foldable
68
68
69import Debug.Trace
69import Debug.Trace
70
70
71−--TODO: The use of Seq in this module could probably be replaced with something
72−--even cheaper. We do need O(1) append, but we don't need associativity until
73−--the very end, when we're smashing everything together. This could be
74−--implemented as a binary tree whose representation isn't associative, but which
75−--doesn't allow any external party to observe the lack of associativity.
76−
77data RequestData ps request = forall s. RequestData !(TagGen ps s) !(NonEmptyDeferred (RequestEnvelope s request))
71data RequestData ps request = forall s. RequestData !(TagGen ps s) !(NonEmptyDeferred (RequestEnvelope s request))
78data ResponseData ps response = forall s. ResponseData !(TagGen ps s) !(TagMap s response)
72data ResponseData ps response = forall s. ResponseData !(TagGen ps s) !(TagMap s response)
79
73