Module

Concur.Core.Patterns

#loopState

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

A very useful combinator for widgets with localised state

#retryUntil

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

Repeat a computation until the value satisfies a predicate

#retryUntilLoop

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

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

The Elm Architecture

#remoteWidget

remoteWidget :: forall m n a void. 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

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

forkActionState :: forall m s. 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

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

A wire can send values up into a local environment

#mapWire

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

Map a Lens over a Wire

#local

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

Setup a local environment with a wire

Modules