Module

Halogen.Store.Monad

#MonadStore

class (MonadEffect m) <= MonadStore a s m | m -> s a where

The MonadStore class captures monads which implement a stored value, along with methods to get, update (via an action type, a), or subscribe to changes in the stored value.

An instance is provided for StoreT, which is the standard way to use the MonadStore class.

Members

Instances

#HalogenStore

type HalogenStore a s = { emitter :: Emitter s, listener :: Listener s, reducer :: s -> a -> s, value :: Ref s }

Instances

#StoreT

newtype StoreT a s m b

Constructors

Instances

#runStoreT

runStoreT :: forall a s q i o m. Monad m => s -> (s -> a -> s) -> Component q i o (StoreT a s m) -> Aff (Component q i o m)

Run a component in the StoreT monad.

Requires an initial value for the store, s, and a reducer that updates the store in response to an action, a.

This can be used directly on the root component of your application to produce a component that Halogen can run, so long as the base monad can be fixed to Aff.

main = launchAff_ do
  body <- Halogen.Aff.awaitBody
  root <- runStoreT initialStore reducer rootComponent
  runUI root unit body

Modules