Module

Halogen.Query

Functions and types used to describe the HalogenF algebra used in a component's eval function.

#Action

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).

#action

action :: forall f. Action f -> f Unit

Takes a data constructor of query algebra f and creates an action.

For example:

data Query a = Tick a

sendTick :: forall o. HalogenIO Query o Aff -> Aff Unit
sendTick app = app.query (action Tick)

#Request

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

request :: forall f a. 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. HalogenIO Query o Aff -> Aff Int
getTickCount app = app.query (request GetTickCount)

#query

query :: forall s f g p o m a. Eq p => p -> g a -> HalogenM s f g p o m (Maybe a)

Sends a query to a child of a component at the specified slot.

#query'

query' :: forall s f g g' m p p' o a. Eq p' => ChildPath g g' p p' -> p -> g a -> HalogenM s f g' p' o m (Maybe a)

Sends a query to a child of a component at the specified slot, using a ChildPath to discriminate the type of child component to query.

#queryAll

queryAll :: forall s f g p o m a. Ord p => g a -> HalogenM s f g p o m (Map p a)

Sends a query to all children of a component.

#queryAll'

queryAll' :: forall s f g g' p p' o m a. Ord p => Eq p' => ChildPath g g' p p' -> g a -> HalogenM s f g' p' o m (Map p a)

Sends a query to all children of a specific type within a component, using a ChildPath to discriminate the type of child component to query.

#getHTMLElementRef

getHTMLElementRef :: forall s f g p o m. RefLabel -> HalogenM s f g p o m (Maybe HTMLElement)

Re-exports from Control.Monad.State.Class

#put

put :: forall m s. MonadState s m => s -> m Unit

Set the state.

#modify_

modify_ :: forall s m. MonadState s m => (s -> s) -> m Unit

#modify

modify :: forall s m. MonadState s m => (s -> s) -> m s

Modify the state by applying a function to the current state. The returned value is the new state value.

#gets

gets :: forall s m a. MonadState s m => (s -> a) -> m a

Get a value which depends on the current state.

#get

get :: forall m s. MonadState s m => m s

Get the current state.

Re-exports from Control.Monad.Trans.Class

#lift

lift :: forall m a t. MonadTrans t => Monad m => m a -> t m a

Re-exports from Effect.Aff.Class

#liftAff

liftAff :: forall m. MonadAff m => Aff ~> m

Re-exports from Effect.Class

#liftEffect

liftEffect :: forall a m. MonadEffect m => Effect a -> m a

Re-exports from Halogen.Query.EventSource

#SubscribeStatus

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

newtype EventSource f m

#eventSource_

eventSource_ :: forall f m. MonadAff m => (Effect Unit -> Effect 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

eventSource :: forall f m a. MonadAff m => ((a -> Effect Unit) -> Effect 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

newtype HalogenM s (f :: Type -> Type) g p o m a

Constructors

Instances

#HalogenF

data HalogenF s (f :: Type -> Type) g p o m a

The Halogen component algebra

Constructors

Instances

#subscribe

subscribe :: forall s f g p o m. 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.

#raise

raise :: forall s f g p o m. o -> HalogenM s f g p o m Unit

Raises an output message for the component.

#mkQuery

mkQuery :: forall s f g p o m a. Eq p => p -> g a -> HalogenM s f g p o m a

#getSlots

getSlots :: forall s f g p o m. HalogenM s f g p o m (List p)

#getRef

getRef :: forall s f g p o m. RefLabel -> HalogenM s f g p o m (Maybe Element)

#fork

fork :: forall s f g p o m a. MonadAff m => HalogenM s f g p o m a -> HalogenM s f g p o m (Error -> m Unit)

#checkSlot

checkSlot :: forall s f g p o m. p -> HalogenM s f g p o m Boolean

Re-exports from Halogen.Query.InputF

#RefLabel

Modules