@@ -74,32 +74,12 @@ module Reflex.Dynamic
7474 , distributeFHListOverDynPure
7575 -- * Unsafe
7676 , unsafeDynamic
77− -- * Deprecated functions
78− , apDyn
79− , attachDyn
80− , attachDynWith
81− , attachDynWithMaybe
82− , collectDyn
83− , combineDyn
84− , distributeDMapOverDyn
85− , distributeFHListOverDyn
86− , forDyn
87− , getDemuxed
88− , joinDyn
89− , mapDyn
90− , mconcatDyn
91− , nubDyn
92− , splitDyn
93− , tagDyn
94− , uniqDyn
95− , uniqDynBy
9677 ) where
9778
9879import Data.Functor.Compose
9980import Data.Functor.Misc
10081import Reflex.Class
10182
102−import Control.Applicative ((<*>))
10383import Control.Monad
10484import Control.Monad.Fix
10585import Control.Monad.Identity
@@ -239,7 +219,7 @@ distributeListOverDynPure =
239219-- | Combine a 'Dynamic' of a 'Map' of 'Dynamic's into a 'Dynamic'
240220-- with the current values of the 'Dynamic's in a map.
241221joinDynThroughMap :: forall t k a. (Reflex t, Ord k) => Dynamic t (Map k (Dynamic t a)) -> Dynamic t (Map k a)
242−joinDynThroughMap = joinDyn . fmap distributeMapOverDynPure
222+joinDynThroughMap = join . fmap distributeMapOverDynPure
243223
244224-- | Print the value of the 'Dynamic' when it is first read and on each
245225-- subsequent change that is observed (as 'traceEvent'), prefixed with the
@@ -550,134 +530,3 @@ instance IsHList (a, b, c, d, e, f) where
550530#if !defined(__GLASGOW_HASKELL__) || __GLASGOW_HASKELL__ < 800
551531 _ -> error "fromHList: impossible" -- Otherwise, GHC complains of a non-exhaustive pattern match; see https://ghc.haskell.org/trac/ghc/ticket/4139
552532#endif
553−
554−--------------------------------------------------------------------------------
555−-- Deprecated functions
556−--------------------------------------------------------------------------------
557−
558−-- | Map a function over a 'Dynamic'.
559−{-# DEPRECATED mapDyn "Use 'return . fmap f' instead of 'mapDyn f'; consider eliminating monadic style" #-}
560−mapDyn :: (Reflex t, Monad m) => (a -> b) -> Dynamic t a -> m (Dynamic t b)
561−mapDyn f = return . fmap f
562−
563−-- | Flipped version of 'mapDyn'.
564−{-# DEPRECATED forDyn "Use 'return . ffor a' instead of 'forDyn a'; consider eliminating monadic style" #-}
565−forDyn :: (Reflex t, Monad m) => Dynamic t a -> (a -> b) -> m (Dynamic t b)
566−forDyn a = return . ffor a
567−
568−-- | Split the 'Dynamic' into two 'Dynamic's, each taking the respective value
569−-- of the tuple.
570−{-# DEPRECATED splitDyn "Use 'return . splitDynPure' instead; consider eliminating monadic style" #-}
571−splitDyn :: (Reflex t, Monad m) => Dynamic t (a, b) -> m (Dynamic t a, Dynamic t b)
572−splitDyn = return . splitDynPure
573−
574−-- | Merge the 'Dynamic' values using their 'Monoid' instance.
575−{-# DEPRECATED mconcatDyn "Use 'return . mconcat' instead; consider eliminating monadic style" #-}
576−mconcatDyn :: forall t m a. (Reflex t, Monad m, Monoid a) => [Dynamic t a] -> m (Dynamic t a)
577−mconcatDyn = return . mconcat
578−
579−-- | This function no longer needs to be monadic; see 'distributeMapOverDynPure'.
580−{-# DEPRECATED distributeDMapOverDyn "Use 'return . distributeDMapOverDynPure' instead; consider eliminating monadic style" #-}
581−distributeDMapOverDyn :: (Reflex t, Monad m, GCompare k) => DMap k (Dynamic t) -> m (Dynamic t (DMap k Identity))
582−distributeDMapOverDyn = return . distributeDMapOverDynPure
583−
584−-- | Merge two 'Dynamic's into a new one using the provided function. The new
585−-- 'Dynamic' changes its value each time one of the original 'Dynamic's changes
586−-- its value.
587−{-# DEPRECATED combineDyn "Use 'return (zipDynWith f a b)' instead of 'combineDyn f a b'; consider eliminating monadic style" #-}
588−combineDyn :: forall t m a b c. (Reflex t, Monad m) => (a -> b -> c) -> Dynamic t a -> Dynamic t b -> m (Dynamic t c)
589−combineDyn f a b = return $ zipDynWith f a b
590−
591−-- | A pseudo applicative version of ap for 'Dynamic'. Example useage:
592−--
593−-- > do
594−-- > person <- Person `mapDyn` dynFirstName
595−-- > `apDyn` dynListName
596−-- > `apDyn` dynAge
597−-- > `apDyn` dynAddress
598−{-# DEPRECATED apDyn "Use 'ffor m (<*> a)' instead of 'apDyn m a'; consider eliminating monadic style, since Dynamics are now Applicative and can be used with applicative style directly" #-}
599−#ifdef USE_TEMPLATE_HASKELL
600−{-# ANN apDyn "HLint: ignore Use fmap" #-}
601−#endif
602−apDyn :: forall t m a b. (Reflex t, Monad m)
603− => m (Dynamic t (a -> b))
604− -> Dynamic t a
605− -> m (Dynamic t b)
606−apDyn m a = fmap (<*> a) m
607−
608−--TODO: The pattern of using hold (sample b0) can be reused in various places as a safe way of building certain kinds of Dynamics; see if we can factor this out
609−-- | This function no longer needs to be monadic, so it has been replaced by
610−-- 'demuxed', which is pure.
611−{-# DEPRECATED getDemuxed "Use 'return . demuxed d' instead of 'getDemuxed d'; consider eliminating monadic style" #-}
612−getDemuxed :: (Reflex t, Monad m, Eq k) => Demux t k -> k -> m (Dynamic t Bool)
613−getDemuxed d = return . demuxed d
614−
615−-- | This function no longer needs to be monadic, so it has been replaced by
616−-- 'distributeFHListOverDynPure', which is pure.
617−{-# DEPRECATED distributeFHListOverDyn "Use 'return . distributeFHListOverDynPure' instead; consider eliminating monadic style" #-}
618−distributeFHListOverDyn :: forall t m l. (Reflex t, Monad m, RebuildSortedHList l) => FHList (Dynamic t) l -> m (Dynamic t (HList l))
619−distributeFHListOverDyn = return . distributeFHListOverDynPure
620−
621−-- | This function no longer needs to be monadic, so it has been replaced by
622−-- 'collectDynPure', which is pure.
623−{-# DEPRECATED collectDyn "Use 'return . collectDynPure' instead; consider eliminating monadic style" #-}
624−collectDyn :: ( RebuildSortedHList (HListElems b)
625− , IsHList a, IsHList b
626− , AllAreFunctors (Dynamic t) (HListElems b)
627− , Reflex t, Monad m
628− , HListElems a ~ FunctorList (Dynamic t) (HListElems b)
629− ) => a -> m (Dynamic t b)
630−collectDyn = return . collectDynPure
631−
632−-- | This function has been renamed to 'tagPromptlyDyn' to clarify its
633−-- semantics.
634−{-# DEPRECATED tagDyn "Use 'tagPromptlyDyn' instead" #-}
635−tagDyn :: Reflex t => Dynamic t a -> Event t b -> Event t a
636−tagDyn = tagPromptlyDyn
637−
638−-- | This function has been renamed to 'attachPromptlyDyn' to clarify its
639−-- semantics.
640−{-# DEPRECATED attachDyn "Use 'attachPromptlyDyn' instead" #-}
641−attachDyn :: Reflex t => Dynamic t a -> Event t b -> Event t (a, b)
642−attachDyn = attachPromptlyDyn
643−
644−-- | This function has been renamed to 'attachPromptlyDynWith' to clarify its
645−-- semantics.
646−{-# DEPRECATED attachDynWith "Use 'attachPromptlyDynWith' instead" #-}
647−attachDynWith :: Reflex t => (a -> b -> c) -> Dynamic t a -> Event t b -> Event t c
648−attachDynWith = attachPromptlyDynWith
649−
650−-- | This function has been renamed to 'attachPromptlyDynWithMaybe' to clarify
651−-- its semantics.
652−{-# DEPRECATED attachDynWithMaybe "Use 'attachPromptlyDynWithMaybe' instead" #-}
653−attachDynWithMaybe :: Reflex t => (a -> b -> Maybe c) -> Dynamic t a -> Event t b -> Event t c
654−attachDynWithMaybe = attachPromptlyDynWithMaybe
655−
656−-- | Combine an inner and outer 'Dynamic' such that the resulting 'Dynamic''s
657−-- current value will always be equal to the current value's current value, and
658−-- will change whenever either the inner or the outer (or both) values change.
659−{-# DEPRECATED joinDyn "Use 'join' instead" #-}
660−joinDyn :: Reflex t => Dynamic t (Dynamic t a) -> Dynamic t a
661−joinDyn = join
662−
663−-- | WARNING: This function is only pure if @a@'s 'Eq' instance tests
664−-- representational equality. Use 'holdUniqDyn' instead, which is pure in all
665−-- circumstances. Also, note that, unlike 'nub', this function does not prevent
666−-- all recurrences of a value, only consecutive recurrences.
667−{-# DEPRECATED nubDyn "Use 'holdUniqDyn' instead; note that it returns a MonadHold action rather than a pure Dynamic" #-}
668−nubDyn :: (Reflex t, Eq a) => Dynamic t a -> Dynamic t a
669−nubDyn = uniqDyn
670−
671−-- | WARNING: This function is only pure if @a@'s 'Eq' instance tests
672−-- representational equality. Use 'holdUniqDyn' instead, which is pure in all
673−-- circumstances.
674−{-# DEPRECATED uniqDyn "Use 'holdUniqDyn' instead; note that it returns a MonadHold action rather than a pure Dynamic" #-}
675−uniqDyn :: (Reflex t, Eq a) => Dynamic t a -> Dynamic t a
676−uniqDyn = uniqDynBy (==)
677−
678−-- | WARNING: This function is impure. Use 'holdUniqDynBy' instead.
679−{-# DEPRECATED uniqDynBy "Use 'holdUniqDynBy' instead; note that it returns a MonadHold action rather than a pure Dynamic" #-}
680−uniqDynBy :: Reflex t => (a -> a -> Bool) -> Dynamic t a -> Dynamic t a
681−uniqDynBy eq d =
682− let e' = attachWithMaybe (\x x' -> if x' `eq` x then Nothing else Just x') (current d) (updated d)
683− in unsafeDynamic (current d) e'