Module

Concur.Core.Patterns

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

#loopState Source

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 Source

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

Repeat a computation until the value satisfies a predicate

#retryUntilLoop Source

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 Source

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

The Elm Architecture

#remoteWidget Source

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 Source

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 Source

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 Source

newtype Wire :: (Type -> Type) -> Type -> Typenewtype Wire m a

A wire can send values up into a local environment

Constructors

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

Instances

#mapWire Source

mapWire :: forall m s a. Alt m => MonadEffect m => MonadAff m => Plus m => Lens' s a -> Wire m s -> Wire m a

Map a Lens over a Wire

#local Source

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

Setup a local environment with a wire

#with Source

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

#send Source

send :: forall m a. MonadEffect m => MonadAff m => Plus m => Wire m a -> a -> m Void