Module

Specular.FRP

Package
purescript-specular
Repository
restaumatic/purescript-specular

Re-exports from Specular.FRP.Base

#Pull Source

newtype Pull a

Pull is a computation that reads a value given current time.

Invariant: Pull computations are always idempotent (forall x :: Pull a. x *> x = x).

Instances

#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

#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

#Behavior Source

newtype Behavior a

Behaviors are time-changing values that can be read, but not subscribed to.

Instances

#MonadFRP Source

class (MonadEffect m, MonadCleanup m) <= MonadFRP m 

A "type class alias" for the constraints required by most FRP primitives.

Instances

#uniqDynBy Source

uniqDynBy :: forall a m. MonadFRP m => (a -> a -> Boolean) -> Dynamic a -> m (Dynamic a)

Make a Dynamic that only changes value when the input Dynamic changes value, and the new value is not equal to the previous value with respect to the given equality test.

#traceEventIO Source

traceEventIO :: forall a. (a -> Effect Unit) -> Event a -> Event a

#traceDynIO Source

traceDynIO :: forall a. (a -> Effect Unit) -> Dynamic a -> Dynamic a

#tagDyn Source

tagDyn :: forall a. Dynamic a -> Event Unit -> Event a

#switch Source

switch :: forall a. Dynamic (Event a) -> Event a

Make an Event that occurs when the current value of the given Dynamic (an Event) occurs.

#subscribeEvent_Impl Source

subscribeEvent_Impl :: forall a m. MonadCleanup m => MonadEffect m => (a -> Effect Unit) -> Event a -> m Unit

#subscribeEvent_ Source

subscribeEvent_ :: forall a m. MonadEffect m => MonadCleanup m => (a -> Effect Unit) -> Event a -> m Unit

#subscribeDyn_ Source

subscribeDyn_ :: forall a m. MonadFRP m => (a -> Effect Unit) -> Dynamic a -> m Unit

#subscribeDyn Source

subscribeDyn :: forall b a m. MonadFRP m => (a -> Effect b) -> Dynamic a -> m (Dynamic b)

#sampleAt Source

sampleAt :: forall b a. Event (a -> b) -> Behavior a -> Event b

#readBehavior Source

readBehavior :: forall a. Behavior a -> Pull a

Read a value of a Behavior.

#pull Source

pull :: forall a m. MonadEffect m => Pull a -> m a

#newEvent Source

newEvent :: forall a m. 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 a m. MonadEffect m => a -> m { behavior :: Behavior a, set :: a -> Effect Unit }

Create a new Behavior whose value can be modified outside a frame.

#never Source

never :: forall a. Event a

An Event that never occurs.

#mergeEvents Source

mergeEvents :: forall c b a. (a -> Behavior c) -> (b -> Behavior c) -> (a -> b -> Behavior c) -> Event a -> Event b -> Event c

#leftmost Source

leftmost :: forall a. Array (Event a) -> Event a

An Event that occurs when any of the events occur. If some of them occur simultaneously, the occurence value is that of the leftmost one.

#latestJust Source

latestJust :: forall a m. 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.

#holdUniqDynBy Source

holdUniqDynBy :: forall a m. MonadFRP m => (a -> a -> Boolean) -> a -> Event a -> m (Dynamic a)

#holdDyn Source

holdDyn :: forall a m. MonadFRP m => a -> Event a -> m (Dynamic a)

holdDyn initialValue event returns a Dynamic that starts with initialValue, and changes to the occurence value of event when event fires

#for Source

for :: forall b a f. Functor f => f a -> (a -> b) -> f b

Flipped map.

Useful in conjunction with dynamic: Instead of dynamic $ map (\x -> longExpression x) dyn, you can write dynamic $ for dyn $ \x -> longExpression x.

#foldDynMaybeImpl Source

foldDynMaybeImpl :: forall b a m. MonadCleanup m => MonadEffect m => (a -> b -> Maybe b) -> b -> Event a -> m (Dynamic b)

#foldDynMaybe Source

foldDynMaybe :: forall b a m. 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.

#foldDynImpl Source

foldDynImpl :: forall b a m. MonadCleanup m => MonadEffect m => (a -> b -> b) -> b -> Event a -> m (Dynamic b)

#foldDyn Source

foldDyn :: forall b a m. 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.

#filterMapEvent Source

filterMapEvent :: forall b a. (a -> Maybe b) -> Event a -> Event b

#filterEvent Source

filterEvent :: forall a. (a -> Boolean) -> Event a -> Event a

#current Source

current :: forall a. Dynamic a -> Behavior a

The Behavior representing the current value of the Dynamic. When it is changing (the change event occurs), it has the new value.

The value of current x is always the value of the latest occurence of changed x, if it has ever occured.

#changed_ Source

changed_ :: forall a. Dynamic a -> Event Unit

An Event that fires every time the Dynamic changes.

#changed Source

changed :: forall a. Dynamic a -> Event a

An Event that fires with the new value every time the Dynamic changes.

#attachDynWith Source

attachDynWith :: forall c b a. (a -> b -> c) -> Dynamic a -> Event b -> Event c

Re-exports from Specular.FRP.Fix

#FixFRP Source

class FixFRP input output | output -> input, input -> output where

Members

Instances

#FixFRPRecord Source

class FixFRPRecord ro_list ri ro | ro_list -> ri ro where

Members

Instances

#fixFRP_ Source

fixFRP_ :: forall m output input. FixFRP input output => MonadFRP m => (input -> m output) -> m Unit

#fixEvent Source

fixEvent :: forall b a m. MonadFRP m => (Event a -> m (Tuple (Event a) b)) -> m b

#fixDyn Source

fixDyn :: forall b a m. MonadFRP m => (WeakDynamic a -> m (Tuple (Dynamic a) b)) -> m b

Re-exports from Specular.FRP.Replaceable

#weakDynamic_ Source

weakDynamic_ :: forall m. MonadReplace m => MonadFRP m => WeakDynamic (m Unit) -> m Unit

#weakDynamic Source

weakDynamic :: forall a m. MonadReplace m => MonadFRP m => WeakDynamic (m a) -> m (WeakDynamic a)

#dynamic_ Source

dynamic_ :: forall m. MonadReplace m => MonadFRP m => Dynamic (m Unit) -> m Unit

#dynamic Source

dynamic :: forall a m. MonadReplace m => MonadFRP m => Dynamic (m a) -> m (Dynamic a)

Re-exports from Specular.FRP.WeakDynamic

#WeakDynamic Source

newtype WeakDynamic a

A primitive similar to Dynamic. The difference is: while Dynamic always has a value, WeakDynamic has a value always after some point, but for some time after construction it may be without value.

A Dynamic can be always converted to a WeakDynamic using weaken.

Instances

#weaken Source

weaken :: forall a. Dynamic a -> WeakDynamic a

Convert a Dynamic to a WeakDynamic. It will have the same value as the original Dynamic, and will change whenever the original Dynamic changes.

#uniqWeakDynBy Source

uniqWeakDynBy :: forall a m. MonadFRP m => (a -> a -> Boolean) -> WeakDynamic a -> m (WeakDynamic a)

Make a WeakDynamic that only changes value when the input WeakDynamic changes value, and the new value is not equal to the previous value with respect to the given equality test.

#unWeakDynamic Source

unWeakDynamic :: forall a. WeakDynamic a -> Dynamic (Maybe a)

#tagWeakDyn Source

tagWeakDyn :: forall a. WeakDynamic a -> Event Unit -> Event a

#switchWeakDyn Source

switchWeakDyn :: forall a. WeakDynamic (Event a) -> Event a

Make an Event that occurs when the given WeakDynamic has a value, and the value (an Event) occurs.

#subscribeWeakDyn_ Source

subscribeWeakDyn_ :: forall a m. MonadFRP m => (a -> Effect Unit) -> WeakDynamic a -> m Unit

Invoke the handler immediately if the WeakDynamic has a value currently, and invoke it every time it changes, until cleanup.

#subscribeWeakDyn Source

subscribeWeakDyn :: forall b a m. MonadFRP m => (a -> Effect b) -> WeakDynamic a -> m (WeakDynamic b)

Invoke the handler immediately if the WeakDynamic has a value currently, and invoke it every time it changes, until cleanup.

#holdWeakDyn Source

holdWeakDyn :: forall a m. MonadFRP m => Event a -> m (WeakDynamic a)

Make a WeakDynamic that will have no value, but will acquire one when the Event fires. It will also change every time the Event fires.

#changedW Source

changedW :: forall a. WeakDynamic a -> Event a

An Event that fires every time a WeakDynamic changes, with the new value.

#attachWeakDynWith Source

attachWeakDynWith :: forall c b a. (a -> b -> c) -> WeakDynamic a -> Event b -> Event c