on 63cbeab help sign in
src/Reflex/Dynamic.hs+10
since splitsnapshots
unifiedsplit
@@ -34,6 +34,7 @@ module Reflex.Dynamic
34 , attachPromptlyDyn
34 , attachPromptlyDyn
35 , attachPromptlyDynWith
35 , attachPromptlyDynWith
36 , attachPromptlyDynWithMaybe
36 , attachPromptlyDynWithMaybe
37+ , improvingMaybe
37 , foldDyn
38 , foldDyn
38 , foldDynM
39 , foldDynM
39 , foldDynMaybe
40 , foldDynMaybe
@@ -84,6 +85,7 @@ import Prelude hiding (mapM, mapM_)
84
85
85import Data.Functor.Misc
86import Data.Functor.Misc
86import Reflex.Class
87import Reflex.Class
88+import Reflex.PostBuild.Class
87
89
88import Control.Applicative ((<*>))
90import Control.Applicative ((<*>))
89import Control.Monad hiding (forM, forM_, mapM, mapM_)
91import Control.Monad hiding (forM, forM_, mapM, mapM_)
@@ -251,6 +253,14 @@ attachPromptlyDynWithMaybe f d e =
251 These (_, b) a -> f a b -- Both events are firing, so use the newer value
253 These (_, b) a -> f a b -- Both events are firing, so use the newer value
252 That _ -> Nothing -- The tagging event isn't firing, so don't fire
254 That _ -> Nothing -- The tagging event isn't firing, so don't fire
253
255
256+-- | Dynamic Maybe that can only update from Nothing to Just or Just to Just (i.e., cannot revert to Nothing)
257+improvingMaybe :: (MonadHold t m, PostBuild t m) => Dynamic t (Maybe a) -> m (Dynamic t (Maybe a))
258+improvingMaybe a = do
259+ postBuild <- getPostBuild
260+ holdDyn Nothing $ fmapMaybe (fmap Just) $ leftmost [ updated a
261+ , tagPromptlyDyn a postBuild
262+ ]
263+
254--------------------------------------------------------------------------------
264--------------------------------------------------------------------------------
255-- Demux
265-- Demux
256--------------------------------------------------------------------------------
266--------------------------------------------------------------------------------