Module

Concur.Core.FRP

Package
purescript-concur-core
Repository
purescript-concur/purescript-concur-core

#SignalT Source

type SignalT :: (Type -> Type) -> Type -> Typetype SignalT m a = Cofree m a

Poor man's FRP implementation for Concur. I am experimenting with the smallest possible amount of FRP which can still be useful. A Widget can be considered to be a one-shot Event. (There is no stream of events in Concur). Signals then are never-ending widget loops that allow access to their last return value. This last produced value allows composition with other widgets even for never-ending widgets.

#Signal Source

type Signal v a = SignalT (Widget v) a

A Signal specific to Widgets

#step Source

step :: forall m a. a -> m (SignalT m a) -> SignalT m a

Construct a signal from an initial value, and a step widget

#display Source

display :: forall m. m (SignalT m Unit) -> SignalT m Unit

Display a widget which returns a continuation

#fireOnce Source

fireOnce :: forall m a. Monad m => Plus m => m a -> SignalT m (Maybe a)

Fires a widget once then stop. This will reflow when a parent signal reflows Starts as Nothing. Then switches to Just returnVal after the Widget is done

#fireOnce_ Source

fireOnce_ :: forall m. Monad m => Plus m => m Unit -> SignalT m Unit

Similar to fireOnce, but discards the return value

#justWait Source

justWait :: forall m a b. Monad m => Alternative m => b -> SignalT m (Maybe a) -> (a -> SignalT m b) -> SignalT m b

Wait until we get a Just value from a signal

#justEffect Source

justEffect :: forall m a b. MonadEffect m => Monad m => Alternative m => b -> Effect a -> (a -> SignalT m b) -> SignalT m b

Run an effectful computation, and do something with the result

#always Source

always :: forall m a. Monad m => Alternative m => a -> SignalT m a

A constant signal

#update Source

update :: forall m a. SignalT m a -> m (SignalT m a)

Update signal to a new value

#poll Source

poll :: forall m a. Monad m => SignalT m (m a) -> m (SignalT m a)

Construct a signal by polling a signal with a nested widget for values

#hold Source

hold :: forall m a. Monad m => a -> m a -> SignalT m a

Create a signal which repeatedly invokes a widget for values. E.g. signal False checkbox will return a signal which reflects the current value of the checkbox.

#loopW Source

loopW :: forall m a. Monad m => a -> (a -> m a) -> SignalT m a

Create a signal which repeatedly invokes a widget function for values, looping in the prev value.

#loopS Source

loopS :: forall m a. Monad m => a -> (a -> SignalT m a) -> SignalT m a

Loop a signal so that the return value is passed to the beginning again.

#foldp Source

foldp :: forall m a b. Functor m => (a -> b -> a) -> a -> SignalT m b -> SignalT m a

Loop a signal so that the return value is passed to the beginning again. Folding signals. Similar to how signals used to work in Elm. This can be used to implement simple stateful Signals. e.g. counter = fold (\n _ -> n+1) 0 clicks

#dyn Source

dyn :: forall m a b. Monad m => SignalT m a -> m b

Consume a closed signal to make a widget

#oneShot Source

oneShot :: forall m a. Monad m => SignalT m (Maybe a) -> m a

Run a signal once and return its value

#demand Source

demand :: forall m a. Monad m => SignalT m (Maybe a) -> m a

#demand' Source

demand' :: forall m a. Monad m => (Maybe a -> SignalT m (Maybe a)) -> m a

#demandLoop Source

demandLoop :: forall m a s. Monad m => Alternative m => s -> (s -> SignalT m (Either s a)) -> m a

#stateLoopS Source

stateLoopS :: forall m a s. Monad m => Alternative m => s -> (s -> SignalT m (Either s a)) -> SignalT m (Maybe a)

#debounce Source

debounce :: forall m a. Monad m => Alt m => MonadAff m => Number -> a -> (a -> m a) -> SignalT m a