Module

Specular.FRP

Package
purescript-specular
Repository
restaumatic/purescript-specular

Re-exports from Specular.FRP.Base

#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

import Partial.Unsafe (unsafeCrashWith) import Unsafe.Coerce (unsafeCoerce) 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 m a. 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.

#uniqDyn Source

uniqDyn :: forall m a. MonadFRP m => Eq a => Dynamic a -> m (Dynamic a)

#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.

switch (pure e) = e

#subscribeEvent_ Source

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

#subscribeDyn_ Source

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

#subscribeDyn Source

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

#sampleAt Source

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

#readDynamic Source

readDynamic :: forall m a. MonadEffect m => Dynamic a -> m a

#readBehavior Source

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

Read a value of a Behavior.

#pull Source

pull :: forall a m. MonadEffect m => Effect a -> m 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.

#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.

#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.

#never Source

never :: forall a. Event a

An Event that never occurs.

#map2 Source

map2 :: forall a b c. (a -> b -> c) -> Dynamic a -> Dynamic b -> Dynamic 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 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.

#holdUniqDynBy Source

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

#holdDyn Source

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

#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.

#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.

#filterMapEvent Source

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

#filterJustEvent Source

filterJustEvent :: forall a. Event (Maybe a) -> Event a

#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 a b c. (a -> b -> c) -> Dynamic a -> Event b -> Event c

#annotated Source

annotated :: forall a. String -> Dynamic a -> Dynamic a

#annotate Source

annotate :: forall m a. MonadEffect m => Dynamic a -> String -> m Unit

#_subscribeEvent Source

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 input output m. FixFRP input output => MonadFRP m => (input -> m output) -> m Unit

#fixEvent Source

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

#fixDyn Source

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

Re-exports from Specular.FRP.Replaceable

#withDynamic_ Source

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

#whenJustD Source

whenJustD :: forall m a. MonadReplace m => MonadFRP m => Dynamic (Maybe a) -> (Dynamic a -> m Unit) -> m Unit

#whenD Source

whenD :: forall m. MonadFRP m => MonadReplace m => Dynamic Boolean -> m Unit -> m Unit

Execute a monadic action in a Replaceable monad only if the given Dynamic has value true.

#weakDynamic_ Source

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

#weakDynamic Source

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

#unlessD Source

unlessD :: forall m. MonadFRP m => MonadReplace m => Dynamic Boolean -> m Unit -> m Unit

Execute a monadic action in a Replaceable monad only if the given Dynamic has value true.

#dynamic_ Source

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

#dynamic Source

dynamic :: forall m a. 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 m a. 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 m a. 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 m a b. 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 m a. 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 a b c. (a -> b -> c) -> WeakDynamic a -> Event b -> Event c