on develop help sign in
Make numberOccurrences* strict

Otherwise they leak memory

commitbe224dfc5305714256b13764d105e39bb796873f authorRyan Trinkle <ryan.trinkle@gmail.com> dateTue 27 Feb 2018, 01:16 (9 years ago) parentc2b8ccd
1 file changed+3−2
src/Reflex/Class.hs+3−2
src/Reflex/Class.hs+3−2
@@ -1,3 +1,4 @@
1+{-# LANGUAGE BangPatterns #-}
12{-# LANGUAGE ConstraintKinds #-}
23{-# LANGUAGE CPP #-}
34{-# LANGUAGE DefaultSignatures #-}
@@ -1113,12 +1114,12 @@ numberOccurrences = numberOccurrencesFrom 0
11131114-- | Assign a number to each occurence of the given 'Event'
11141115{-# INLINE numberOccurrencesFrom #-}
11151116numberOccurrencesFrom :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t (b, a))
1116−numberOccurrencesFrom = mapAccum_ (\n a -> (n + 1, (n, a)))
1117+numberOccurrencesFrom = mapAccum_ (\n a -> let !next = n + 1 in (next, (n, a)))
11171118
11181119-- | Assign a number to each occurence of the given 'Event'; discard the occurrences' values
11191120{-# INLINE numberOccurrencesFrom_ #-}
11201121numberOccurrencesFrom_ :: (Reflex t, MonadHold t m, MonadFix m, Num b) => b -> Event t a -> m (Event t b)
1121−numberOccurrencesFrom_ = mapAccum_ (\n _ -> (n + 1, n))
1122+numberOccurrencesFrom_ = mapAccum_ (\n _ -> let !next = n + 1 in (next, n))
11221123
11231124-- | This is used to sample the value of a 'Behavior' using an 'Event'.
11241125--