Halogen.Query
- Package
- purescript-halogen
- Repository
- slamdata/purescript-halogen
Functions and types used to describe the HalogenF
algebra used in a
component's eval
function.
#Action Source
type Action f = Unit -> f Unit
Type synonym for an "action" - An action only causes effects and has no result value.
In a query algebra, an action is any constructor that carries the algebra's type variable as a value. For example:
data Query a
= SomeAction a
| SomeOtherAction String a
| NotAnAction (Boolean -> a)
Both SomeAction
and SomeOtherAction
have a
as a value so they are
considered actions, whereas NotAnAction
has a
as the result of a
function so is considered to be a "request" (see below).
#Request Source
type Request f a = (a -> a) -> f a
Type synonym for an "request" - a request can cause effects as well as fetching some information from a component.
In a query algebra, an action is any constructor that carries the algebra's type variable as the return value of a function. For example:
data Query a = SomeRequest (Boolean -> a)
#request Source
request :: forall a f. Request f a -> f a
Takes a data constructor of query algebra f
and creates a request.
For example:
data Query a = GetTickCount (Int -> a)
getTickCount :: forall o eff. HalogenIO Query o (Aff (HalogenEffects eff)) -> Aff (HalogenEffects eff) Int
getTickCount app = app.query (request GetTickCount)
#getHTMLElementRef Source
getHTMLElementRef :: forall m o p g f s. RefLabel -> HalogenM s f g p o m (Maybe HTMLElement)
Re-exports from Control.Monad.Aff.Class
Re-exports from Control.Monad.Eff.Class
Re-exports from Control.Monad.State.Class
#put Source
put :: forall s m. MonadState s m => s -> m Unit
Set the state.
#modify Source
modify :: forall m s. MonadState s m => (s -> s) -> m Unit
Modify the state by applying a function to the current state.
#gets Source
gets :: forall a m s. MonadState s m => (s -> a) -> m a
Get a value which depends on the current state.
#get Source
get :: forall s m. MonadState s m => m s
Get the current state.
Re-exports from Control.Monad.Trans.Class
#lift Source
lift :: forall t a m. MonadTrans t => Monad m => m a -> t m a
Re-exports from Halogen.Query.EventSource
#SubscribeStatus Source
data SubscribeStatus
The status of an EventSource
subscription. When a query raised by an
EventSource
evaluates to Done
the producer will be unsubscribed from.
Constructors
Instances
#EventSource Source
newtype EventSource f m
#eventSource_ Source
eventSource_ :: forall eff m f. MonadAff (avar :: AVAR | eff) m => (Eff (avar :: AVAR | eff) Unit -> Eff (avar :: AVAR | eff) Unit) -> f SubscribeStatus -> EventSource f m
Creates an EventSource
for a callback that accepts no arguments.
- The first argument is the function that attaches the listener.
- The second argument is the query to raise whenever the listener is triggered.
#eventSource Source
eventSource :: forall eff a m f. MonadAff (avar :: AVAR | eff) m => ((a -> Eff (avar :: AVAR | eff) Unit) -> Eff (avar :: AVAR | eff) Unit) -> (a -> Maybe (f SubscribeStatus)) -> EventSource f m
Creates an EventSource
for a callback that accepts one argument.
- The first argument is the function that attaches the listener.
- The second argument is a handler that optionally produces a value in
f
.
Re-exports from Halogen.Query.HalogenM
#HalogenM Source
newtype HalogenM s (f :: Type -> Type) g p o m a
Constructors
Instances
Functor (HalogenM s f g p o m)
Apply (HalogenM s f g p o m)
Applicative (HalogenM s f g p o m)
Bind (HalogenM s f g p o m)
Monad (HalogenM s f g p o m)
(MonadEff eff m) => MonadEff eff (HalogenM s f g p o m)
(MonadAff eff m) => MonadAff eff (HalogenM s f g p o m)
Parallel (HalogenAp s f g p o m) (HalogenM s f g p o m)
MonadTrans (HalogenM s f g p o)
MonadRec (HalogenM s f g p o m)
MonadState s (HalogenM s f g p o m)
(MonadAsk r m) => MonadAsk r (HalogenM s f g p o m)
(MonadTell w m) => MonadTell w (HalogenM s f g p o m)
#HalogenF Source
data HalogenF s (f :: Type -> Type) g p o m a
The Halogen component algebra
Constructors
State (s -> Tuple a s)
Subscribe (EventSource f m) a
Lift (m a)
Halt String
GetSlots (List p -> a)
CheckSlot p (Boolean -> a)
ChildQuery p (Coyoneda g a)
Raise o a
Par (HalogenAp s f g p o m a)
Fork (Fork (HalogenM s f g p o m) a)
GetRef RefLabel (Maybe Foreign -> a)
Instances
#subscribe Source
subscribe :: forall m o p g f s. EventSource f m -> HalogenM s f g p o m Unit
Provides a way of having a component subscribe to an EventSource
from
within an Eval
function.
Re-exports from Halogen.Query.InputF
- Modules
- Halogen
- Halogen.
Aff - Halogen.
Aff. Driver - Halogen.
Aff. Driver. Eval - Halogen.
Aff. Driver. State - Halogen.
Aff. Effects - Halogen.
Aff. Util - Halogen.
Component - Halogen.
Component. ChildPath - Halogen.
Component. Profunctor - Halogen.
Data. OrdBox - Halogen.
Data. Prism - Halogen.
HTML - Halogen.
HTML. Core - Halogen.
HTML. Elements - Halogen.
HTML. Elements. Keyed - Halogen.
HTML. Events - Halogen.
HTML. Properties - Halogen.
HTML. Properties. ARIA - Halogen.
Query - Halogen.
Query. EventSource - Halogen.
Query. ForkF - Halogen.
Query. HalogenM - Halogen.
Query. InputF - Halogen.
VDom. Driver