on develop help sign in
Mark distributeListOverDynPure as deprecated, remove duplication.
8d70b34Divam
src/Reflex/Class.hs+10−1
@@ -991,7 +991,16 @@ distributeListOverDyn = distributeListOverDynWith id
991
991
992-- | Create a new 'Dynamic' by applying a combining function to a list of 'Dynamic's
992-- | Create a new 'Dynamic' by applying a combining function to a list of 'Dynamic's
993distributeListOverDynWith :: Reflex t => ([a] -> b) -> [Dynamic t a] -> Dynamic t b
993distributeListOverDynWith :: Reflex t => ([a] -> b) -> [Dynamic t a] -> Dynamic t b
994−distributeListOverDynWith f = fmap (f . map (\(Const2 _ :=> Identity v) -> v) . DMap.toList) . distributeDMapOverDynPure . DMap.fromList . map (\(k, v) -> Const2 k :=> v) . zip [0 :: Int ..]
994+distributeListOverDynWith f =
995+ fmap (f . map fromDSum . DMap.toAscList) .
996+ distributeDMapOverDynPure .
997+ DMap.fromDistinctAscList .
998+ zipWith toDSum [0..]
999+ where
1000+ toDSum :: Int -> Dynamic t a -> DSum (Const2 Int a) (Dynamic t)
1001+ toDSum k v = Const2 k :=> v
1002+ fromDSum :: DSum (Const2 Int a) Identity -> a
1003+ fromDSum (Const2 _ :=> Identity v) = v
995
1004
996-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
1005-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
997-- unless the second supplied 'Event' occurs simultaneously.
1006-- unless the second supplied 'Event' occurs simultaneously.
src/Reflex/Dynamic.hs+2−10
@@ -220,17 +220,9 @@ distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithF
220
220
221-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
221-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
222-- non-'Dynamic' elements, preserving the order of the elements.
222-- non-'Dynamic' elements, preserving the order of the elements.
223+{-# DEPRECATED distributeListOverDynPure "Use 'distributeListOverDyn' instead" #-}
223distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
224distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
224−distributeListOverDynPure =
225+distributeListOverDynPure = distributeListOverDyn
225− fmap (map fromDSum . DMap.toAscList) .
226− distributeDMapOverDynPure .
227− DMap.fromDistinctAscList .
228− zipWith toDSum [0..]
229− where
230− toDSum :: Int -> Dynamic t a -> DSum (Const2 Int a) (Dynamic t)
231− toDSum k v = Const2 k :=> v
232− fromDSum :: DSum (Const2 Int a) Identity -> a
233− fromDSum (Const2 _ :=> Identity v) = v
234
226
235--TODO: Generalize this to functors other than Maps
227--TODO: Generalize this to functors other than Maps
236-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'
228-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'