Module

Concur.Core.FRP

#SignalT

type 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

type Signal v a = SignalT (Widget v) a

A Signal specific to Widgets

#step

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

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

#display

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

Display a widget which returns a continuation

#fireOnce

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_

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

Similar to fireOnce, but discards the return value

#justWait

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

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

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

A constant signal

#update

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

Update signal to a new value

#poll

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

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

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

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

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

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

Consume a closed signal to make a widget

#oneShot

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

Run a signal once and return its value

#demand

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

#demand'

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

#demandLoop

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

#stateLoopS

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

#debounce

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

Modules