on develop help sign in
Merge pull request #264 from reflex-frp/dn-minor-code-fixes
6cb5850Ali Abrar
src/Reflex/Class.hs+10−1
@@ -1093,7 +1093,16 @@ distributeListOverDyn = distributeListOverDynWith id
1093
1093
1094-- | Create a new 'Dynamic' by applying a combining function to a list of 'Dynamic's
1094-- | Create a new 'Dynamic' by applying a combining function to a list of 'Dynamic's
1095distributeListOverDynWith :: Reflex t => ([a] -> b) -> [Dynamic t a] -> Dynamic t b
1095distributeListOverDynWith :: Reflex t => ([a] -> b) -> [Dynamic t a] -> Dynamic t b
1096−distributeListOverDynWith f = fmap (f . map (\(Const2 _ :=> Identity v) -> v) . DMap.toList) . distributeDMapOverDynPure . DMap.fromList . map (\(k, v) -> Const2 k :=> v) . zip [0 :: Int ..]
1096+distributeListOverDynWith f =
1097+ fmap (f . map fromDSum . DMap.toAscList) .
1098+ distributeDMapOverDynPure .
1099+ DMap.fromDistinctAscList .
1100+ zipWith toDSum [0..]
1101+ where
1102+ toDSum :: Int -> Dynamic t a -> DSum (Const2 Int a) (Dynamic t)
1103+ toDSum k v = Const2 k :=> v
1104+ fromDSum :: DSum (Const2 Int a) Identity -> a
1105+ fromDSum (Const2 _ :=> Identity v) = v
1097
1106
1098-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
1107-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
1099-- unless the second supplied 'Event' occurs simultaneously.
1108-- unless the second supplied 'Event' occurs simultaneously.
src/Reflex/Dynamic.hs+2−10
@@ -203,17 +203,9 @@ distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithF
203
203
204-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
204-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
205-- non-'Dynamic' elements, preserving the order of the elements.
205-- non-'Dynamic' elements, preserving the order of the elements.
206+{-# DEPRECATED distributeListOverDynPure "Use 'distributeListOverDyn' instead" #-}
206distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
207distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
207−distributeListOverDynPure =
208+distributeListOverDynPure = distributeListOverDyn
208− fmap (map fromDSum . DMap.toAscList) .
209− distributeDMapOverDynPure .
210− DMap.fromDistinctAscList .
211− zipWith toDSum [0..]
212− where
213− toDSum :: Int -> Dynamic t a -> DSum (Const2 Int a) (Dynamic t)
214− toDSum k v = Const2 k :=> v
215− fromDSum :: DSum (Const2 Int a) Identity -> a
216− fromDSum (Const2 _ :=> Identity v) = v
217
209
218--TODO: Generalize this to functors other than Maps
210--TODO: Generalize this to functors other than Maps
219-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'
211-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'