Module

Halogen.Component

Package
purescript-halogen
Repository
slamdata/purescript-halogen

#Component Source

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' Source

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

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 Source

mkComponent :: forall m o i p g f s h. 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 Source

unComponent :: forall r m o i f h. (forall p g s. 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 Source

type ComponentSpec h s f i o m = { eval :: f ~> (ComponentDSL s f o m), initialState :: i -> s, receiver :: i -> Maybe (f Unit), render :: s -> h Void (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 Source

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 Source

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 Source

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

Builds a component with no possible children.

#LifecycleComponentSpec Source

type LifecycleComponentSpec h s f i o m = { eval :: f ~> (ComponentDSL s f o m), finalizer :: Maybe (f Unit), initialState :: i -> s, initializer :: Maybe (f Unit), receiver :: i -> Maybe (f Unit), render :: s -> h Void (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 Source

lifecycleComponent :: forall m o i f s h. 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 Source

type ParentComponentSpec h s f g p i o m = { eval :: f ~> (HalogenM s f g p o m), initialState :: i -> s, receiver :: i -> Maybe (f Unit), render :: s -> h (ComponentSlot h g m p (f Unit)) (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 Source

parentComponent :: forall m o i p g f s h. 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 Source

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 Source

type ParentDSL = HalogenM

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

#ParentLifecycleComponentSpec Source

type ParentLifecycleComponentSpec h s f g p i o m = { eval :: f ~> (HalogenM s f g p o m), finalizer :: Maybe (f Unit), initialState :: i -> s, initializer :: Maybe (f Unit), receiver :: i -> Maybe (f Unit), render :: s -> h (ComponentSlot h g m p (f Unit)) (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 Source

lifecycleParentComponent :: forall m o i p g f s h. 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 Source

hoist :: forall m' m o i f h. 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 Source

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

Instances

#mkComponentSlot Source

mkComponentSlot :: forall o q j p m z g h. 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 Source

unComponentSlot :: forall r q p m g h. (forall o j z. 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 Source

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