Specular.FRP.Base
- Package
- purescript-specular
- Repository
- restaumatic/purescript-specular
#Event Source
newtype Event a
A source of occurences.
During a frame, an Event occurs at most once with a value of type a.
Event is a functor. It is not, however, an Applicative. There is no
meaningful interpretation of pure
(when would the event occur?).
There is an interpretation of apply
(Event that fires when the input
events coincide), but it's not very useful.
Instances
#pull Source
pull :: forall a m. MonadEffect m => Effect a -> m a
#readBehavior Source
readBehavior :: forall a. Behavior a -> Effect a
Read a value of a Behavior.
#Dynamic Source
newtype Dynamic a
Dynamic a
represents a dynamically changing value of type a
. The
current value may be queried at any time (using current
), and it's
possible to be notified of changes (using changed
).
Instances
#attachDynWith Source
attachDynWith :: forall a b c. (a -> b -> c) -> Dynamic a -> Event b -> Event c
#latestJust Source
latestJust :: forall m a. MonadFRP m => Dynamic (Maybe a) -> m (Dynamic (Maybe a))
Returns a Dynamic that holds the latest Just
value of the input Dynamic
after execution of this function. If the input currently has value Nothing
, the resulting
Dynamic will have the value Nothing
until the input changes to a Just
.
The resulting Dynamic changes when the input changes to a value that is a Just
,
and doesn't change when the input changes to Nothing
.
#readDynamic Source
readDynamic :: forall m a. MonadEffect m => Dynamic a -> m a
#newDynamic Source
newDynamic :: forall m a. MonadEffect m => a -> m { dynamic :: Dynamic a, modify :: (a -> a) -> Effect Unit, read :: Effect a, set :: a -> Effect Unit }
effectCrash :: forall a. String -> a
effectCrash msg = unsafeCoerce (_ -> unsafeCrashWith msg)
Construct a new root Dynamic that can be changed from Effect
-land.
#foldDyn Source
foldDyn :: forall m a b. MonadFRP m => (a -> b -> b) -> b -> Event a -> m (Dynamic b)
foldDyn f x e
- Make a Dynamic that will have the initial value x
,
and every time e
fires, its value will update by applying f
to the
event occurence value and the old value.
On cleanup, the Dynamic will stop updating in response to the event.
#foldDynMaybe Source
foldDynMaybe :: forall m a b. MonadFRP m => (a -> b -> Maybe b) -> b -> Event a -> m (Dynamic b)
Like foldDyn
, but the Dynamic will not update if the folding function
returns Nothing.
#holdUniqDynBy Source
holdUniqDynBy :: forall m a. MonadFRP m => (a -> a -> Boolean) -> a -> Event a -> m (Dynamic a)
#newEvent Source
newEvent :: forall m a. MonadEffect m => m { event :: Event a, fire :: a -> Effect Unit }
Create an Event that can be triggered externally.
Each fire
will run a frame where the event occurs.
#newBehavior Source
newBehavior :: forall m a. MonadEffect m => a -> m { behavior :: Behavior a, set :: a -> Effect Unit }
Create a new Behavior whose value can be modified outside a frame.
#subscribeEvent_ Source
subscribeEvent_ :: forall m a. MonadEffect m => MonadCleanup m => (a -> Effect Unit) -> Event a -> m Unit
#subscribeDyn Source
subscribeDyn :: forall m a b. MonadFRP m => (a -> Effect b) -> Dynamic a -> m (Dynamic b)
#_subscribeEvent Source
_subscribeEvent :: forall a. EffectFn2 (a -> Effect Unit) (Event a) Unsubscribe
#MonadFRP Source
class MonadFRP :: (Type -> Type) -> Constraint
class (MonadEffect m, MonadCleanup m) <= MonadFRP m
A "type class alias" for the constraints required by most FRP primitives.
Instances
(MonadEffect m, MonadCleanup m) => MonadFRP m
- Modules
- Control.
Monad. Cleanup - Control.
Monad. Replace - Specular.
Debug - Specular.
Dom. Browser - Specular.
Dom. Builder - Specular.
Dom. Builder. Class - Specular.
Dom. Element - Specular.
Dom. Element. Class - Specular.
Dom. Node. Class - Specular.
Dom. Widget - Specular.
Dom. Widgets. Button - Specular.
Dom. Widgets. Input - Specular.
Dom. Widgets. RadioGroup - Specular.
Dom. Widgets. Select - Specular.
FRP - Specular.
FRP. Async - Specular.
FRP. Base - Specular.
FRP. Fix - Specular.
FRP. List - Specular.
FRP. Replaceable - Specular.
FRP. WeakDynamic - Specular.
Internal. Effect - Specular.
Internal. Incremental - Specular.
Internal. Incremental. Array - Specular.
Internal. Incremental. Effect - Specular.
Internal. Incremental. Global - Specular.
Internal. Incremental. Mutable - Specular.
Internal. Incremental. MutableArray - Specular.
Internal. Incremental. Node - Specular.
Internal. Incremental. Optional - Specular.
Internal. Incremental. PriorityQueue - Specular.
Internal. Incremental. Ref - Specular.
Internal. Profiling - Specular.
Internal. Queue - Specular.
Internal. RIO - Specular.
Profiling - Specular.
Ref
This instance allows use of the Boolean operators
(||)
and(&&)
directly onDynamic Bool
.