-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | External reference with reactivity support -- -- The package provides you with IORef that has attached reflex -- Event. Each time the variable changes the event fires. It is -- very useful for communication with external event sources or using it -- as environment level state. @package reflex-external-ref @version 1.0.3.1 -- | External reference with reactivity support. The reference is needed in -- glue code between reflex and external libs where you cannot sample -- from dynamics with MonadSample. module Reflex.ExternalRef -- | Holds value of type a and provides ways for notifying FRP -- network about changes of the variable. -- -- This abstraction is helpful for storing counters, lists of internal -- resources and so on. It is designed to be updated from outputs of FRP -- network, not from outer world. data ExternalRef t a ExternalRef :: !IORef a -> !Event t a -> !a -> IO () -> ExternalRef t a -- | Storage of value (do not change this by yourself, use helpers) [externalRef] :: ExternalRef t a -> !IORef a -- | Event that fires when value is changed [externalEvent] :: ExternalRef t a -> !Event t a -- | Method of updating value of previous event [externalFire] :: ExternalRef t a -> !a -> IO () -- | Creation of external ref in host monad newExternalRef :: (MonadIO m, TriggerEvent t m) => a -> m (ExternalRef t a) -- | Read current value of external reference readExternalRef :: MonadIO m => ExternalRef t a -> m a -- | Write new value to external reference and notify FRP network. The -- function evaluates the value to WNF. writeExternalRef :: MonadIO m => ExternalRef t a -> a -> m () -- | Atomically modify an external ref and notify FRP network. The function -- evaluates the value to WNF. modifyExternalRef :: MonadIO m => ExternalRef t a -> (a -> (a, b)) -> m b -- | Atomically modify an external ref and notify FRP network. The function -- evaluates the value to WNF. Returns nothing modifyExternalRef_ :: MonadIO m => ExternalRef t a -> (a -> a) -> m () -- | If the function evaluates to Just then Atomically modify an external -- ref and notify FRP network. The function evaluates the value to WNF. -- Return the Maybe result of function's evaluation modifyExternalRefMaybe :: MonadIO m => ExternalRef t a -> (a -> Maybe (a, b)) -> m (Maybe b) -- | If the function evaluates to Just then Atomically modify an external -- ref and notify FRP network. The function evaluates the value to WNF. -- Returns nothing The function discards the result modifyExternalRefMaybe_ :: MonadIO m => ExternalRef t a -> (a -> Maybe a) -> m () -- | Modify (not atomically) an external ref and notify FRP network. The -- function evaluates the value to WNF. modifyExternalRefM :: MonadIO m => ExternalRef t a -> (a -> m (a, b)) -> m b -- | Modify (not atomically) an external ref and notify FRP network. The -- function evaluates the value to WNF. modifyExternalRefM_ :: MonadIO m => ExternalRef t a -> (a -> m a) -> m () -- | If the function evaluates to Just then Modify (not atomically) an -- external ref and notify FRP network. The function evaluates the value -- to WNF. modifyExternalRefMaybeM :: MonadIO m => ExternalRef t a -> (a -> m (Maybe (a, b))) -> m (Maybe b) -- | If the function evaluates to Just then Modify (not atomically) an -- external ref and notify FRP network. The function evaluates the value -- to WNF. The function discards the result modifyExternalRefMaybeM_ :: MonadIO m => ExternalRef t a -> (a -> m (Maybe a)) -> m () -- | Construct a behavior from external reference externalRefBehavior :: (MonadHold t m, MonadIO m) => ExternalRef t a -> m (Behavior t a) -- | Get dynamic that tracks value of the internal ref externalRefDynamic :: (MonadHold t m, MonadIO m) => ExternalRef t a -> m (Dynamic t a) -- | Create external ref that tracks content of dynamic. Editing of the ref -- has no effect on the original dynamic. externalFromDynamic :: (MonadHold t m, TriggerEvent t m, PerformEvent t m, Reflex t, MonadIO m, MonadIO (Performable m)) => Dynamic t a -> m (ExternalRef t a) -- | Creates external ref as a result of "fmapping" a function to the -- original ref. ExternalRef t is not a true Functior, since it requres -- monadic action to "fmap" Editing of the new ref has no effect on the -- original dynamic. fmapExternalRef :: (MonadIO m, TriggerEvent t m, PerformEvent t m, MonadIO (Performable m)) => (a -> b) -> ExternalRef t a -> m (ExternalRef t b) instance GHC.Generics.Generic (Reflex.ExternalRef.ExternalRef t a) instance Control.DeepSeq.NFData (Reflex.ExternalRef.ExternalRef t a)