on develop help sign in
Mark distributeListOverDynPure as deprecated, remove duplication.
commit8d70b34d7f0c5ea76d85d89dfdd01eb61a989123 authorDivam <dfordivam@gmail.com> dateThu 24 Jan 2019, 19:36 (8 years ago) parent53bfa66
2 files changed+12−11
src/Reflex/Class.hs+10−1 src/Reflex/Dynamic.hs+2−10
src/Reflex/Class.hs+10−1
@@ -991,7 +991,16 @@ distributeListOverDyn = distributeListOverDynWith id
991991
992992-- | Create a new 'Dynamic' by applying a combining function to a list of 'Dynamic's
993993distributeListOverDynWith :: 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
9951004
9961005-- | Create a new 'Event' that occurs when the first supplied 'Event' occurs
9971006-- unless the second supplied 'Event' occurs simultaneously.
src/Reflex/Dynamic.hs+2−10
@@ -220,17 +220,9 @@ distributeMapOverDynPure = fmap dmapToMap . distributeDMapOverDynPure . mapWithF
220220
221221-- | Convert a list with 'Dynamic' elements into a 'Dynamic' of a list with
222222-- non-'Dynamic' elements, preserving the order of the elements.
223+{-# DEPRECATED distributeListOverDynPure "Use 'distributeListOverDyn' instead" #-}
223224distributeListOverDynPure :: Reflex t => [Dynamic t v] -> Dynamic t [v]
224−distributeListOverDynPure =
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
225+distributeListOverDynPure = distributeListOverDyn
234226
235227--TODO: Generalize this to functors other than Maps
236228-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'