Module

Concur.Core.FRP

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

#Signal Source

type Signal v a = Cofree (Widget v) 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.

#step Source

step :: forall v a. a -> Widget v (Signal v a) -> Signal v a

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

#display Source

display :: forall v. Widget v (Signal v Unit) -> Signal v Unit

Display a widget which returns a continuation

#fireOnce Source

fireOnce :: forall v a. Monoid v => Widget v a -> Signal v (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 v. Monoid v => Widget v Unit -> Signal v Unit

Similar to fireOnce, but discards the return value

#justWait Source

justWait :: forall v a b. Monoid v => b -> Signal v (Maybe a) -> (a -> Signal v b) -> Signal v b

Wait until we get a Just value from a signal

#justEffect Source

justEffect :: forall v a b. Monoid v => b -> Effect a -> (a -> Signal v b) -> Signal v b

Run an effectful computation, and do something with the result

#always Source

always :: forall v a. Monoid v => a -> Signal v a

A constant signal

#update Source

update :: forall v a. Signal v a -> Widget v (Signal v a)

Update signal to a new value

#poll Source

poll :: forall v a. Signal v (Widget v a) -> Widget v (Signal v a)

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

#hold Source

hold :: forall v a. Monoid v => a -> Widget v a -> Signal v 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 v a. a -> (a -> Widget v a) -> Signal v a

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

#loopS Source

loopS :: forall v a. Monoid v => a -> (a -> Signal v a) -> Signal v a

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

#foldp Source

foldp :: forall v a b. (a -> b -> a) -> a -> Signal v b -> Signal v 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 v a b. Signal v a -> Widget v b

Consume a closed signal to make a widget

#oneShot Source

oneShot :: forall v a. Signal v (Maybe a) -> Widget v a

Run a signal once and return its value

#demand Source

demand :: forall v a. Signal v (Maybe a) -> Widget v a

#demand' Source

demand' :: forall v a. (Maybe a -> Signal v (Maybe a)) -> Widget v a

#demandLoop Source

demandLoop :: forall v a s. Monoid v => s -> (s -> Signal v (Either s a)) -> Widget v a

#stateLoopS Source

stateLoopS :: forall v a s. Monoid v => s -> (s -> Signal v (Either s a)) -> Signal v (Maybe a)

#debounce Source

debounce :: forall a v. Monoid v => Number -> a -> (a -> Widget v a) -> Signal v a