#loopState Source

loopState :: forall s a m. Monad m => s -> (s -> m (Either s a)) -> m a

A very useful combinator for widgets with localised state

#retryUntil Source

retryUntil :: forall a m. Monad m => (a -> Boolean) -> m a -> m a

Repeat a computation until the value satisfies a predicate

#retryUntilLoop Source

retryUntilLoop :: forall a m. Monad m => (a -> Boolean) -> (a -> m a) -> a -> m a

Repeat a computation until the value satisfies a predicate, looping in the previous value

#tea Source

tea :: forall x m s a. Monad m => s -> (s -> m a) -> (a -> s -> s) -> m x

The Elm Architecture

#remoteWidget Source

remoteWidget :: forall void a n m. MonadEffect n => MonadAff m => MonadEffect m => Plus m => m a -> n (Tuple (m a) (m void))

Separate the effect of the widget from its result

#forkAction Source

forkAction :: forall b a m. MonadEffect m => MonadAff m => Plus m => m a -> (m a -> m b) -> m b

A common pattern - running a long running action and keeping the GUI responsive Because the action can't be restarted on every gui event, we must fork it off in the beginning

#forkActionState Source

forkActionState :: forall s m. Plus m => MonadAff m => m (s -> s) -> (s -> m s) -> (s -> m s)

Another common variant on the forkAction pattern. The action m (s->s) may take a while (should not be restarted) and returns a state modification function The gui s -> m s takes in the current state, and modifies it on events Note that forkActionState axn has the shape (s -> m s) -> (s -> m s). So it can be "stacked" to fork multiple actions. e.g. forkActionState axn1 $ forkActionState axn2 $ forkActionState axn3 $ render initialState.

#Wire Source

type Wire m a = { receive :: m a, send :: a -> m Void, value :: a }

A wire can send values up into a local environment

#mapWire Source

mapWire :: forall a s m. Functor m => Lens' s a -> Wire m s -> Wire m a

Map a Lens over a Wire

#local Source

local :: forall a r m. Alt m => MonadEffect m => MonadAff m => Plus m => a -> (Wire m a -> m r) -> m r

Setup a local environment with a wire