@@ -34,6 +34,7 @@ module Reflex.Dynamic
3434 , attachPromptlyDyn
3535 , attachPromptlyDynWith
3636 , attachPromptlyDynWithMaybe
37+ , improvingMaybe
3738 , foldDyn
3839 , foldDynM
3940 , foldDynMaybe
@@ -84,6 +85,7 @@ import Prelude hiding (mapM, mapM_)
8485
8586import Data.Functor.Misc
8687import Reflex.Class
88+import Reflex.PostBuild.Class
8789
8890import Control.Applicative ((<*>))
8991import Control.Monad hiding (forM, forM_, mapM, mapM_)
@@ -251,6 +253,14 @@ attachPromptlyDynWithMaybe f d e =
251253 These (_, b) a -> f a b -- Both events are firing, so use the newer value
252254 That _ -> Nothing -- The tagging event isn't firing, so don't fire
253255
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+
254264--------------------------------------------------------------------------------
255265-- Demux
256266--------------------------------------------------------------------------------