Module

Halogen.Component

#Component

data Component (h :: Type -> Type -> Type) (f :: Type -> Type) i o (m :: Type -> Type)

The "public" type for a component, with details of the component internals existentially hidden.

  • h is the type that will be rendered by the component, usually HTML
  • f is the query algebra
  • i is the input value type that will be mapped to an f whenever the parent of this component renders
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#Component'

type Component' h s f g p i o m = { initialState :: i -> s, render :: s -> h (ComponentSlot h g m p (f Unit)) (f Unit), eval :: f ~> (HalogenM s f g p o m), receiver :: i -> Maybe (f Unit), initializer :: Maybe (f Unit), finalizer :: Maybe (f Unit), mkOrdBox :: p -> OrdBox p }

The "private" type for a component.

  • h is the type that will be rendered by the component, usually HTML
  • s is the component's state
  • f is the query algebra for the component itself
  • g is the query algebra for child components
  • p is the slot type for addressing child components
  • i is the input value type that will be mapped to an f whenever the parent of this component renders
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#mkComponent

mkComponent :: forall h s f g p i o m. Component' h s f g p i o m -> Component h f i o m

Makes a Component from a Component', existentially hiding details about the component's state and potential children.

#unComponent

unComponent :: forall h f i o m r. (forall s g p. Component' h s f g p i o m -> r) -> Component h f i o m -> r

Exposes the inner details of a component to a function to produce a new result. The inner details will not be allowed to be revealed in the result of the function - the compiler will complain about an escaped skolem.

#ComponentSpec

type ComponentSpec h s f i o m = { initialState :: i -> s, render :: s -> h Void (f Unit), eval :: f ~> (ComponentDSL s f o m), receiver :: i -> Maybe (f Unit) }

A spec for a component with no possible children.

  • h is the type that will be rendered by the component, usually HTML
  • s is the component's state
  • f is the query algebra
  • i is the input value type that will be mapped to an f whenever the parent of this component renders
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#ComponentHTML

type ComponentHTML f = HTML Void (f Unit)

A convenience synonym for the output type of a render function, for a childless component that renders HTML.

#ComponentDSL

type ComponentDSL s f = HalogenM s f (Const Void) Void

A synonym for HalogenM with some type parameters populated that are not relevant for childless components.

#component

component :: forall h s f i o m. Bifunctor h => ComponentSpec h s f i o m -> Component h f i o m

Builds a component with no possible children.

#LifecycleComponentSpec

type LifecycleComponentSpec h s f i o m = { initialState :: i -> s, render :: s -> h Void (f Unit), eval :: f ~> (ComponentDSL s f o m), receiver :: i -> Maybe (f Unit), initializer :: Maybe (f Unit), finalizer :: Maybe (f Unit) }

A spec for a component with no possible children, including lifecycle inputs.

  • h is the type that will be rendered by the component, usually HTML
  • s is the component's state
  • f is the query algebra
  • i is the input value type that will be mapped to an f whenever the parent of this component renders
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#lifecycleComponent

lifecycleComponent :: forall h s f i o m. Bifunctor h => LifecycleComponentSpec h s f i o m -> Component h f i o m

Builds a component with lifecycle inputs and no possible children.

#ParentComponentSpec

type ParentComponentSpec h s f g p i o m = { initialState :: i -> s, render :: s -> h (ComponentSlot h g m p (f Unit)) (f Unit), eval :: f ~> (HalogenM s f g p o m), receiver :: i -> Maybe (f Unit) }

A spec for a component.

  • h is the type that will be rendered by the component, usually HTML
  • s is the component's state
  • f is the query algebra for the component itself
  • g is the query algebra for child components
  • p is the slot type for addressing child components
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#parentComponent

parentComponent :: forall h s f g p i o m. Ord p => ParentComponentSpec h s f g p i o m -> Component h f i o m

Builds a component that allows for children.

#ParentHTML

type ParentHTML f g p m = HTML (ComponentSlot HTML g m p (f Unit)) (f Unit)

A convenience synonym for the output type of a render function, for a parent component that renders HTML.

#ParentDSL

type ParentDSL = HalogenM

A synonym for just HalogenM. Provided for consistency with ComponentDSL in the non-parent-component case.

#ParentLifecycleComponentSpec

type ParentLifecycleComponentSpec h s f g p i o m = { initialState :: i -> s, render :: s -> h (ComponentSlot h g m p (f Unit)) (f Unit), eval :: f ~> (HalogenM s f g p o m), receiver :: i -> Maybe (f Unit), initializer :: Maybe (f Unit), finalizer :: Maybe (f Unit) }

A spec for a parent component, including lifecycle inputs.

  • h is the type that will be rendered by the component, usually HTML
  • s is the component's state
  • f is the query algebra for the component itself
  • g is the query algebra for child components
  • p is the slot type for addressing child components
  • o is the type for the component's output messages
  • m is the monad used for non-component-state effects

#lifecycleParentComponent

lifecycleParentComponent :: forall h s f g p i o m. Ord p => ParentLifecycleComponentSpec h s f g p i o m -> Component h f i o m

Builds a component with lifecycle inputs that allows for children.

#hoist

hoist :: forall h f i o m m'. Bifunctor h => Functor m' => (m ~> m') -> Component h f i o m -> Component h f i o m'

Changes the component's m type. A use case for this would be to interpret some Free monad as Aff so the component can be used with runUI.

#ComponentSlot

data ComponentSlot (h :: Type -> Type -> Type) (g :: Type -> Type) (m :: Type -> Type) p q

Instances

#mkComponentSlot

mkComponentSlot :: forall h g z m p j q o. p -> (Component h z j o m) -> j -> (j -> Maybe (g Unit)) -> (o -> Maybe q) -> (forall x. g x -> Maybe (z x)) -> ComponentSlot h g m p q

#unComponentSlot

unComponentSlot :: forall h g m p q r. (forall z j o. p -> Component h z j o m -> j -> (j -> Maybe (g Unit)) -> (o -> Maybe q) -> (forall x. g x -> Maybe (z x)) -> r) -> ComponentSlot h g m p q -> r

#hoistSlot

hoistSlot :: forall h g m m' p q. Bifunctor h => Functor m' => (m ~> m') -> ComponentSlot h g m p q -> ComponentSlot h g m' p q

Modules