arbiter-core-0.1.0.0
arbiter-core
Safe HaskellNone
LanguageGHC2024

Arbiter.Core.Selector

Contents

Description

A selector reads payload fields and applies policies. Evaluation returns the selected result. Static inspection returns all reachable policies for migration initialization.

Synopsis

Documentation

type Selector policy payload = Select (Prim policy payload)Source #

A selective description over a payload. Evaluation for a job returns an a. Static inspection returns the reachable policies.

chooseWhen :: (payload -> Bool) -> Selector policy payload a -> Selector policy payload a -> Selector policy payload aSource #

The first selector when the predicate holds, else the second. Policy collection inspects both branches.

Internal

Internal to the arbiter packages. Not covered by the PVP.

data Prim policy payload aSource #

A primitive in a selector. Reads a field of the job, or uses a policy. A used policy is recorded for collection and yielded for building a key.

Instances

Instances details
Functor (Prim policy payload) Source # 
Instance details

Defined in Arbiter.Core.Selector

Methods

fmap :: (a -> b) -> Prim policy payload a -> Prim policy payload b#

(<$) :: a -> Prim policy payload b -> Prim policy payload a#

field :: (payload -> a) -> Selector policy payload aSource #

Read a field of the payload (for predicates or key suffixes).

usePolicy :: policy -> Selector policy payload policySource #

Record a policy for initialization and return it for key construction.

runSelector :: forall policy payload a. payload -> Selector policy payload a -> aSource #

Run a selector against a concrete job to get its result.

collectPolicies :: Ord policy => Selector policy payload a -> Set policySource #

All policies that a selector can reach across all branches.

usesAnyPolicy :: Selector policy payload a -> BoolSource #

Test for a reachable policy. Stop at the first match.

selectByCase :: (Bounded k, Enum k, Eq k) => (payload -> k) -> (k -> Selector policy payload a) -> Selector policy payload aSource #

N-way chooseWhen. Maps the job to a finite tag, then each tag to its selector. Policy collection evaluates every tag in [minBound..maxBound]. The tag's Bounded/Enum and the selector must be total over k.